Areen work¶

We import the data and clean it¶

In total we have 320 rows(participant) but not all of them answer to all the Questions¶

Number of rows: 320
Out[73]:
Timestamp Your Age Your Gender Educational Level Years of Experience Are you aware of the potential health benefits of Magnesium supplements? Where do you get the knowledge about Magnesium benefits ? What food is highest in magnesium ? What are the signs of low magnesium ? What are the health condition does magnesium used for ? ... Magnesium oxide is best indicated for ? Are you aware about Magnesium supplements toxicity ?\n What is the recommended dose of Magnesium supplements that patient needs ? If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ? Which case does Magnesium taken with caution and the dose should be adjusted ? Can Large doses of vitamin D induce severe depletion of Mg ? Is Magnesium safe for pregnant in Eclampsia cases ? What is the side effect behind consuming Magnesium supplements for long term ? Why do you think the reasons behind side effects of using Magnesium ? Do you recommend others by using Magnesium Supplement regularly ?
0 2024-02-09 21:53:34.676 35 Female Master's Degree 12 Yes Self experience Chicken & Meat Muscle spasms Migraine headache ... Constipation Yes 320 for Female & 420 for Male Stop Magnesium until doxycyclin course finished Kidney disorders True 0.0 Muscle weakness Lack of sufficient knowledge Yes
1 2024-02-09 21:54:16.854 42 Female Bachelor's Degree 15 Yes Magnesium supplements Labels Whole grains Muscle spasms Chronic diseases ( Arrhythmia , diabetes ,..) ... Constipation Yes 120 for Female & 220 for Male Stop Magnesium until doxycyclin course finished Gastric discomfort True 0.0 Dihherhea Misuse of Magnesium ( improper dose .. ) Yes
2 2024-02-09 21:54:52.752 44 Male Master's Degree 20 Yes Self experience Chicken & Meat Fatigue Muscle cramps ... Diarrhea Yes 120 for Female & 220 for Male Stop Magnesium until doxycyclin course finished Kidney disorders True 0.0 Low blood pressure Misuse of Magnesium ( improper dose .. ) Yes
3 2024-02-09 21:55:28.994 25 Male Master's Degree 2 Yes Self experience Chicken & Meat Fatigue Muscle cramps ... Urinary antiseptic Yes 120 for Female & 220 for Male Separate the time of the dose by at least 2 to... Kidney disorders True 0.0 Dihherhea Misuse of Magnesium ( improper dose .. ) Yes
4 2024-02-09 21:56:21.355 45 Male Master's Degree 13 No More than one answer is true Whole grains Mood changes Muscle cramps ... Diarrhea Yes 120 for Female & 220 for Male Stop Magnesium until doxycyclin course finished Kidney disorders True 0.0 Dihherhea Misuse of Magnesium ( improper dose .. ) Yes
5 2024-02-09 21:57:02.655 33 Female Bachelor's Degree 10 Yes Scientific Researches Chicken & Meat Fatigue Muscle cramps ... Constipation Yes 120 for Female & 220 for Male Stop Magnesium until doxycyclin course finished Kidney disorders True 0.0 Sleepness Misuse of Magnesium ( improper dose .. ) Yes
6 2024-02-09 22:00:17.486 25 Female Bachelor's Degree 2 Yes More than one answer is true Whole grains Muscle spasms Muscle cramps ... Diarrhea Yes 120 for Female & 220 for Male Stop Magnesium until doxycyclin course finished Kidney disorders True 0.0 Sleepness Misuse of Magnesium ( improper dose .. ) Yes
7 2024-02-09 22:01:03.705 24 Female Bachelor's Degree 2 Yes Magnesium supplements Labels Chicken & Meat Fatigue Muscle cramps ... Urinary antiseptic Yes 120 for Female & 220 for Male Stop Magnesium until doxycyclin course finished Mal-nutrition cases True 0.0 Dihherhea Misuse of Magnesium ( improper dose .. ) Yes
8 2024-02-09 22:01:53.768 37 Male Bachelor's Degree 3 Yes University courses Whole grains Mood changes Migraine headache ... Diarrhea Yes 120 for Female & 220 for Male Stop Magnesium until doxycyclin course finished Kidney disorders True 0.0 Dihherhea Misuse of Magnesium ( improper dose .. ) Yes
9 2024-02-09 22:02:41.057 46 Female Bachelor's Degree 10 Yes Self experience Chicken & Meat Fatigue Muscle cramps ... Urinary antiseptic Yes 120 for Female & 220 for Male Stop Magnesium until doxycyclin course finished Kidney disorders True 0.0 Dihherhea Misuse of Magnesium ( improper dose .. ) Yes

10 rows × 24 columns

Total number of missing values in the dataset: 0
Total number of 'Not Measured' values in the dataset: 0
Number of rows: 316

after cleaning and removing the empty rows the number dropped to 316 rows(participant) ,We are going to work with these rows(participant)¶

Then next we view the columns and their unique values¶

In [76]:
print(df.columns)
Index(['Timestamp', 'Your Age', 'Your Gender ', 'Educational Level ',
       'Years of Experience ',
       'Are you aware of the potential health benefits of Magnesium supplements?',
       'Where do you get the knowledge about Magnesium benefits ?',
       'What food is highest in magnesium ?',
       'What are the signs of low magnesium ?',
       'What are the health condition does magnesium used for  ?',
       'Can magnesium maintained body biological clock balanced ?',
       'Does magnesium help with anxiety ?',
       'What is the main health benefit for Magnesium L-threonate ?',
       'To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?',
       'Magnesium oxide is best indicated for ?',
       'Are you aware about Magnesium supplements toxicity ?\n',
       'What is the recommended dose of Magnesium supplements that patient needs ?',
       'If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?',
       'Which case does Magnesium taken with caution and the dose should be adjusted ?',
       'Can Large doses of vitamin D induce severe depletion of Mg ?',
       'Is Magnesium safe for pregnant in Eclampsia cases ?',
       'What is the side effect behind consuming Magnesium supplements for long term ?',
       'Why do you think the reasons behind side effects of using Magnesium ?',
       'Do you recommend others by using Magnesium Supplement regularly ? '],
      dtype='object')
In [77]:
columns_to_check = ['Educational Level ', 
                    'Are you aware of the potential health benefits of Magnesium supplements?',
                   'Where do you get the knowledge about Magnesium benefits ?',
                   'What food is highest in magnesium ?',
                   'What are the signs of low magnesium ?',
                   'What are the health condition does magnesium used for  ?',
                   'Can magnesium maintained body biological clock balanced ?',
                   'Does magnesium help with anxiety ?',
                   'What is the main health benefit for Magnesium L-threonate ?',
                   'To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?',
                   'Magnesium oxide is best indicated for ?',
                   'Are you aware about Magnesium supplements toxicity ?\n',
                   'What is the recommended dose of Magnesium supplements that patient needs ?',
                   'If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?',
                   'Which case does Magnesium taken with caution and the dose should be adjusted ?',
                   'Can Large doses of vitamin D induce severe depletion of Mg ?',
                   'Is Magnesium safe for pregnant in Eclampsia cases ?',
                   'What is the side effect behind consuming Magnesium supplements for long term ?',
                   'Why do you think the reasons behind side effects of using Magnesium ?',
                   'Do you recommend others by using Magnesium Supplement regularly ? ']

for column in columns_to_check:
    unique_values = df[column].unique()
    print(f"Unique values for '{column}': {unique_values}")
Unique values for 'Educational Level ': ["Master's Degree" "Bachelor's Degree" 'PHD degree']
Unique values for 'Are you aware of the potential health benefits of Magnesium supplements?': ['Yes' 'No']
Unique values for 'Where do you get the knowledge about Magnesium benefits ?': ['Self experience' 'Magnesium supplements Labels'
 'More than one answer is true' 'Scientific Researches'
 'University courses']
Unique values for 'What food is highest in magnesium ?': ['Chicken & Meat' 'Whole grains' 'Sea Food']
Unique values for 'What are the signs of low magnesium ?': ['Muscle spasms' 'Fatigue' 'Mood changes' 'Insomnia' 'All of above']
Unique values for 'What are the health condition does magnesium used for  ?': ['Migraine headache' 'Chronic diseases ( Arrhythmia , diabetes ,..)'
 'Muscle cramps' 'All of above' 'Power and energy']
Unique values for 'Can magnesium maintained body biological clock balanced ?': [False  True]
Unique values for 'Does magnesium help with anxiety ?': ['No' 'Yes']
Unique values for 'What is the main health benefit for Magnesium L-threonate ?': ['Heartburn' 'Brain health' 'Control blood pressure'
 'More than one answer is correct']
Unique values for 'To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?': ['Magnesium carbonate' 'Magnesium oxide' 'Magnesium glycinate'
 'More than one answer is true']
Unique values for 'Magnesium oxide is best indicated for ?': ['Constipation' 'Diarrhea' 'Urinary antiseptic' 'Depression']
Unique values for 'Are you aware about Magnesium supplements toxicity ?
': ['Yes' 'No']
Unique values for 'What is the recommended dose of Magnesium supplements that patient needs ?': ['320 for Female & 420 for Male' '120 for Female & 220 for Male'
 '520 for Female & 620 for Male']
Unique values for 'If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?': ['Stop Magnesium until doxycyclin course finished'
 'Separate the time of the dose by at least 2 to 3 hours'
 'Taking another choice of antibiotic rather than doxycyclin']
Unique values for 'Which case does Magnesium taken with caution and the dose should be adjusted ?': ['Kidney disorders' 'Gastric discomfort' 'Mal-nutrition cases'
 'More than one answer is true']
Unique values for 'Can Large doses of vitamin D induce severe depletion of Mg ?': [ True False]
Unique values for 'Is Magnesium safe for pregnant in Eclampsia cases ?': [0. 1.]
Unique values for 'What is the side effect behind consuming Magnesium supplements for long term ?': ['Muscle weakness' 'Dihherhea' 'Low blood pressure' 'Sleepness'
 'All of above']
Unique values for 'Why do you think the reasons behind side effects of using Magnesium ?': ['Lack of sufficient knowledge' 'Misuse of Magnesium ( improper dose .. )'
 'Lack of instruction about administration from health care provider'
 'More than one answer is true']
Unique values for 'Do you recommend others by using Magnesium Supplement regularly ? ': ['Yes' 'No']

To work with the data we have to change it to a boolean form (True or False) beacease the Questions has answer (Correct Value)¶

In [78]:
dc_df = pd.get_dummies(df , columns = [ 'Your Gender ', 'Educational Level ',
       'Are you aware of the potential health benefits of Magnesium supplements?',
       'Where do you get the knowledge about Magnesium benefits ?',
       'What food is highest in magnesium ?',
       'What are the signs of low magnesium ?',
       'What are the health condition does magnesium used for  ?',
       'Can magnesium maintained body biological clock balanced ?',
       'Does magnesium help with anxiety ?',
       'What is the main health benefit for Magnesium L-threonate ?',
       'To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?',
       'Magnesium oxide is best indicated for ?',
       'Are you aware about Magnesium supplements toxicity ?\n',
       'What is the recommended dose of Magnesium supplements that patient needs ?',
       'If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?',
       'Which case does Magnesium taken with caution and the dose should be adjusted ?',
       'Can Large doses of vitamin D induce severe depletion of Mg ?',
       'Is Magnesium safe for pregnant in Eclampsia cases ?',
       'What is the side effect behind consuming Magnesium supplements for long term ?',
       'Why do you think the reasons behind side effects of using Magnesium ?',
       'Do you recommend others by using Magnesium Supplement regularly ? '])
dc_df.head(10)
Out[78]:
Timestamp Your Age Years of Experience Your Gender _Female Your Gender _Male Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree Are you aware of the potential health benefits of Magnesium supplements?_No Are you aware of the potential health benefits of Magnesium supplements?_Yes ... What is the side effect behind consuming Magnesium supplements for long term ?_Dihherhea What is the side effect behind consuming Magnesium supplements for long term ?_Low blood pressure What is the side effect behind consuming Magnesium supplements for long term ?_Muscle weakness What is the side effect behind consuming Magnesium supplements for long term ?_Sleepness Why do you think the reasons behind side effects of using Magnesium ?_Lack of instruction about administration from health care provider Why do you think the reasons behind side effects of using Magnesium ?_Lack of sufficient knowledge Why do you think the reasons behind side effects of using Magnesium ?_Misuse of Magnesium ( improper dose .. ) Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true Do you recommend others by using Magnesium Supplement regularly ? _No Do you recommend others by using Magnesium Supplement regularly ? _Yes
0 2024-02-09 21:53:34.676 35 12 True False False True False False True ... False False True False False True False False False True
1 2024-02-09 21:54:16.854 42 15 True False True False False False True ... True False False False False False True False False True
2 2024-02-09 21:54:52.752 44 20 False True False True False False True ... False True False False False False True False False True
3 2024-02-09 21:55:28.994 25 2 False True False True False False True ... True False False False False False True False False True
4 2024-02-09 21:56:21.355 45 13 False True False True False True False ... True False False False False False True False False True
5 2024-02-09 21:57:02.655 33 10 True False True False False False True ... False False False True False False True False False True
6 2024-02-09 22:00:17.486 25 2 True False True False False False True ... False False False True False False True False False True
7 2024-02-09 22:01:03.705 24 2 True False True False False False True ... True False False False False False True False False True
8 2024-02-09 22:01:53.768 37 3 False True True False False False True ... True False False False False False True False False True
9 2024-02-09 22:02:41.057 46 10 True False True False False False True ... True False False False False False True False False True

10 rows × 71 columns

In [79]:
dc_df.dtypes
Out[79]:
Timestamp                                                                                                         datetime64[ns]
Your Age                                                                                                                   int64
Years of Experience                                                                                                        int64
Your Gender _Female                                                                                                         bool
Your Gender _Male                                                                                                           bool
                                                                                                                       ...      
Why do you think the reasons behind side effects of using Magnesium ?_Lack of sufficient knowledge                          bool
Why do you think the reasons behind side effects of using Magnesium ?_Misuse of Magnesium ( improper dose .. )              bool
Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true                          bool
Do you recommend others by using Magnesium Supplement regularly ? _No                                                       bool
Do you recommend others by using Magnesium Supplement regularly ? _Yes                                                      bool
Length: 71, dtype: object
In [80]:
# Assuming your DataFrame is named df_new and you want to save it to a file named 'new_data.xlsx'
#dc_df.to_excel('new_data1.xlsx', index=False)

small describtion about the Age and Years of Experience¶

In [81]:
dc_df.describe()
Out[81]:
Timestamp Your Age Years of Experience
count 316 316.000000 316.000000
mean 2024-02-21 00:45:27.498607872 34.268987 10.566456
min 2024-02-09 21:53:34.676000 22.000000 1.000000
25% 2024-02-10 17:49:49.080999936 28.000000 5.000000
50% 2024-02-12 21:36:15.685999872 31.000000 8.000000
75% 2024-03-03 17:09:38.880750080 40.000000 15.000000
max 2024-03-08 19:48:43.180000 60.000000 32.000000
std NaN 8.537896 7.354861
In [82]:
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [83]:
# Iterate over each column and plot a histogram
for column in df.columns:
    try:
        plt.figure()
        plt.hist(df[column], bins=5)
        plt.xlabel(column)
        plt.ylabel('Frequency')
        plt.title(f'Histogram of {column}')
        plt.show()
    except Exception as e:
        print(f"Error plotting histogram for column '{column}': {e}")
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Error plotting histogram for column 'Can magnesium maintained body biological clock balanced ?': numpy boolean subtract, the `-` operator, is not supported, use the bitwise_xor, the `^` operator, or the logical_xor function instead.
C:\Users\samir\miniconda3\Lib\site-packages\matplotlib\axes\_axes.py:6859: RuntimeWarning: Converting input from bool to <class 'numpy.uint8'> for compatibility.
  m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs)
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Error plotting histogram for column 'Can Large doses of vitamin D induce severe depletion of Mg ?': numpy boolean subtract, the `-` operator, is not supported, use the bitwise_xor, the `^` operator, or the logical_xor function instead.
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [84]:
# Iterate over each column and plot a box plot
for column in df.columns:
    plt.figure()
    sns.boxplot(data=df[column])
    plt.title(f'Box Plot of {column}')
    plt.show()
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [85]:
# Drop non-numeric columns
numeric_df = df.select_dtypes(include=[np.number])

# Compute correlation matrix
correlation_matrix = numeric_df.corr()
print(correlation_matrix)
                                                    Your Age  \
Your Age                                            1.000000   
Years of Experience                                 0.924087   
Is Magnesium safe for pregnant in Eclampsia cas...  0.038843   

                                                    Years of Experience   \
Your Age                                                        0.924087   
Years of Experience                                             1.000000   
Is Magnesium safe for pregnant in Eclampsia cas...             -0.005000   

                                                    Is Magnesium safe for pregnant in Eclampsia cases ?  
Your Age                                                                                     0.038843    
Years of Experience                                                                         -0.005000    
Is Magnesium safe for pregnant in Eclampsia cas...                                           1.000000    
In [86]:
print(dc_df.columns)
Index(['Timestamp', 'Your Age', 'Years of Experience ', 'Your Gender _Female',
       'Your Gender _Male', 'Educational Level _Bachelor's Degree',
       'Educational Level _Master's Degree', 'Educational Level _PHD degree',
       'Are you aware of the potential health benefits of Magnesium supplements?_No',
       'Are you aware of the potential health benefits of Magnesium supplements?_Yes',
       'Where do you get the knowledge about Magnesium benefits ?_Magnesium supplements Labels',
       'Where do you get the knowledge about Magnesium benefits ?_More than one answer is true',
       'Where do you get the knowledge about Magnesium benefits ?_Scientific Researches',
       'Where do you get the knowledge about Magnesium benefits ?_Self experience',
       'Where do you get the knowledge about Magnesium benefits ?_University courses',
       'What food is highest in magnesium ?_Chicken & Meat',
       'What food is highest in magnesium ?_Sea Food',
       'What food is highest in magnesium ?_Whole grains',
       'What are the signs of low magnesium ?_All of above',
       'What are the signs of low magnesium ?_Fatigue',
       'What are the signs of low magnesium ?_Insomnia',
       'What are the signs of low magnesium ?_Mood changes',
       'What are the signs of low magnesium ?_Muscle spasms',
       'What are the health condition does magnesium used for  ?_All of above',
       'What are the health condition does magnesium used for  ?_Chronic diseases ( Arrhythmia , diabetes ,..)',
       'What are the health condition does magnesium used for  ?_Migraine headache',
       'What are the health condition does magnesium used for  ?_Muscle cramps',
       'What are the health condition does magnesium used for  ?_Power and energy',
       'Can magnesium maintained body biological clock balanced ?_False',
       'Can magnesium maintained body biological clock balanced ?_True',
       'Does magnesium help with anxiety ?_No',
       'Does magnesium help with anxiety ?_Yes',
       'What is the main health benefit for Magnesium L-threonate ?_Brain health',
       'What is the main health benefit for Magnesium L-threonate ?_Control blood pressure',
       'What is the main health benefit for Magnesium L-threonate ?_Heartburn',
       'What is the main health benefit for Magnesium L-threonate ?_More than one answer is correct',
       'To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium carbonate',
       'To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate',
       'To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium oxide',
       'To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_More than one answer is true',
       'Magnesium oxide is best indicated for ?_Constipation',
       'Magnesium oxide is best indicated for ?_Depression',
       'Magnesium oxide is best indicated for ?_Diarrhea',
       'Magnesium oxide is best indicated for ?_Urinary antiseptic',
       'Are you aware about Magnesium supplements toxicity ?\n_No',
       'Are you aware about Magnesium supplements toxicity ?\n_Yes',
       'What is the recommended dose of Magnesium supplements that patient needs ?_120 for Female & 220 for Male',
       'What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male',
       'What is the recommended dose of Magnesium supplements that patient needs ?_520 for Female & 620 for Male',
       'If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours',
       'If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Stop Magnesium until doxycyclin course finished',
       'If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Taking another choice of antibiotic rather than doxycyclin',
       'Which case does Magnesium taken with caution and the dose should be adjusted ?_Gastric discomfort',
       'Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders',
       'Which case does Magnesium taken with caution and the dose should be adjusted ?_Mal-nutrition cases',
       'Which case does Magnesium taken with caution and the dose should be adjusted ?_More than one answer is true',
       'Can Large doses of vitamin D induce severe depletion of Mg ?_False',
       'Can Large doses of vitamin D induce severe depletion of Mg ?_True',
       'Is Magnesium safe for pregnant in Eclampsia cases ?_0.0',
       'Is Magnesium safe for pregnant in Eclampsia cases ?_1.0',
       'What is the side effect behind consuming Magnesium supplements for long term ?_All of above',
       'What is the side effect behind consuming Magnesium supplements for long term ?_Dihherhea',
       'What is the side effect behind consuming Magnesium supplements for long term ?_Low blood pressure',
       'What is the side effect behind consuming Magnesium supplements for long term ?_Muscle weakness',
       'What is the side effect behind consuming Magnesium supplements for long term ?_Sleepness',
       'Why do you think the reasons behind side effects of using Magnesium ?_Lack of instruction about administration from health care provider',
       'Why do you think the reasons behind side effects of using Magnesium ?_Lack of sufficient knowledge',
       'Why do you think the reasons behind side effects of using Magnesium ?_Misuse of Magnesium ( improper dose .. )',
       'Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true',
       'Do you recommend others by using Magnesium Supplement regularly ? _No',
       'Do you recommend others by using Magnesium Supplement regularly ? _Yes'],
      dtype='object')

The P value calulated for all questions and age column¶

In [87]:
columns_to_iterate = dc_df.columns[3:]
for column in columns_to_iterate:
    group1 = dc_df[dc_df[column]]['Your Age']
    group2 = dc_df[~dc_df[column]]['Your Age']
    t_statistic, p_value = stats.ttest_ind(group1, group2)
    print(f"\n{column},Age")
    print(f"\nT-statistic: {t_statistic}, p-value: {p_value}")
Your Gender _Female,Age

T-statistic: -0.8354282315663758, p-value: 0.4041118601134909

Your Gender _Male,Age

T-statistic: 0.8354282315663758, p-value: 0.4041118601134909

Educational Level _Bachelor's Degree,Age

T-statistic: -2.9025457697763497, p-value: 0.003963340794291541

Educational Level _Master's Degree,Age

T-statistic: 0.5926544370281476, p-value: 0.5538389985194547

Educational Level _PHD degree,Age

T-statistic: 4.0835944306622025, p-value: 5.6327797470779135e-05

Are you aware of the potential health benefits of Magnesium supplements?_No,Age

T-statistic: 1.676192371049795, p-value: 0.0946958437804924

Are you aware of the potential health benefits of Magnesium supplements?_Yes,Age

T-statistic: -1.676192371049795, p-value: 0.0946958437804924

Where do you get the knowledge about Magnesium benefits ?_Magnesium supplements Labels,Age

T-statistic: 0.22624418421987122, p-value: 0.8211587089068493

Where do you get the knowledge about Magnesium benefits ?_More than one answer is true,Age

T-statistic: -1.5340684180861084, p-value: 0.1260197537559025

Where do you get the knowledge about Magnesium benefits ?_Scientific Researches,Age

T-statistic: 1.5240491834712722, p-value: 0.12850292355763393

Where do you get the knowledge about Magnesium benefits ?_Self experience,Age

T-statistic: 0.6767441977939261, p-value: 0.4990664890464457

Where do you get the knowledge about Magnesium benefits ?_University courses,Age

T-statistic: -0.8885323356346969, p-value: 0.3749346131811856

What food is highest in magnesium ?_Chicken & Meat,Age

T-statistic: -3.3330670068297032, p-value: 0.0009616389958858085

What food is highest in magnesium ?_Sea Food,Age

T-statistic: -0.2790602166587788, p-value: 0.7803823187939611

What food is highest in magnesium ?_Whole grains,Age

T-statistic: 3.2435174514925067, p-value: 0.0013077278491200558

What are the signs of low magnesium ?_All of above,Age

T-statistic: 0.8470527114960184, p-value: 0.39761087433929143

What are the signs of low magnesium ?_Fatigue,Age

T-statistic: -2.3198426245652, p-value: 0.020990348119288307

What are the signs of low magnesium ?_Insomnia,Age

T-statistic: 1.4922463422182466, p-value: 0.1366385875640793

What are the signs of low magnesium ?_Mood changes,Age

T-statistic: 0.5503619853624857, p-value: 0.5824624178865856

What are the signs of low magnesium ?_Muscle spasms,Age

T-statistic: -0.2735077932764549, p-value: 0.7846427161733962

What are the health condition does magnesium used for  ?_All of above,Age

T-statistic: 1.6228985141237113, p-value: 0.10561461089005765

What are the health condition does magnesium used for  ?_Chronic diseases ( Arrhythmia , diabetes ,..),Age

T-statistic: 2.0421583453997054, p-value: 0.04197097770274058

What are the health condition does magnesium used for  ?_Migraine headache,Age

T-statistic: -0.8265902099377354, p-value: 0.40909702795471037

What are the health condition does magnesium used for  ?_Muscle cramps,Age

T-statistic: -1.8847141906772136, p-value: 0.060391834108822255

What are the health condition does magnesium used for  ?_Power and energy,Age

T-statistic: -0.46523503666641, p-value: 0.6420856335298124

Can magnesium maintained body biological clock balanced ?_False,Age

T-statistic: 0.7941325056856334, p-value: 0.4277180459845418

Can magnesium maintained body biological clock balanced ?_True,Age

T-statistic: -0.7941325056856334, p-value: 0.4277180459845418

Does magnesium help with anxiety ?_No,Age

T-statistic: -0.9182259358849842, p-value: 0.359205363007454

Does magnesium help with anxiety ?_Yes,Age

T-statistic: 0.9182259358849842, p-value: 0.359205363007454

What is the main health benefit for Magnesium L-threonate ?_Brain health,Age

T-statistic: 0.18100235257393563, p-value: 0.8564825025857463

What is the main health benefit for Magnesium L-threonate ?_Control blood pressure,Age

T-statistic: 1.6671586176929396, p-value: 0.096479896768541

What is the main health benefit for Magnesium L-threonate ?_Heartburn,Age

T-statistic: -1.9800170414070988, p-value: 0.048574368059256336

What is the main health benefit for Magnesium L-threonate ?_More than one answer is correct,Age

T-statistic: 0.005346906971383837, p-value: 0.9957372011660574

To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium carbonate,Age

T-statistic: 0.2845940309766847, p-value: 0.776142782410442

To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate,Age

T-statistic: -0.04102878183982576, p-value: 0.9672990259360532

To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium oxide,Age

T-statistic: -0.07262178280651732, p-value: 0.9421533285317502

To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_More than one answer is true,Age

T-statistic: -0.25387788300583736, p-value: 0.7997560609969013

Magnesium oxide is best indicated for ?_Constipation,Age

T-statistic: -1.0916684262648524, p-value: 0.27581578693611264

Magnesium oxide is best indicated for ?_Depression,Age

T-statistic: 1.759395630371191, p-value: 0.07948417844171513

Magnesium oxide is best indicated for ?_Diarrhea,Age

T-statistic: -1.7523712423430593, p-value: 0.08068604406850526

Magnesium oxide is best indicated for ?_Urinary antiseptic,Age

T-statistic: 0.9996173763466008, p-value: 0.31826540975144624

Are you aware about Magnesium supplements toxicity ?
_No,Age

T-statistic: 0.24699840891468558, p-value: 0.8050708667493114

Are you aware about Magnesium supplements toxicity ?
_Yes,Age

T-statistic: -0.24699840891468558, p-value: 0.8050708667493114

What is the recommended dose of Magnesium supplements that patient needs ?_120 for Female & 220 for Male,Age

T-statistic: -1.8004968866564877, p-value: 0.07274177174119151

What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male,Age

T-statistic: 0.20261309171816472, p-value: 0.8395686756916849

What is the recommended dose of Magnesium supplements that patient needs ?_520 for Female & 620 for Male,Age

T-statistic: 1.7671526429063227, p-value: 0.07817399565321657

If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours,Age

T-statistic: -0.008918985111553892, p-value: 0.9928894376497912

If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Stop Magnesium until doxycyclin course finished,Age

T-statistic: -1.0207896394270723, p-value: 0.30813993613857954

If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Taking another choice of antibiotic rather than doxycyclin,Age

T-statistic: 1.1722301864153528, p-value: 0.24199325498110377

Which case does Magnesium taken with caution and the dose should be adjusted ?_Gastric discomfort,Age

T-statistic: 0.9304732360033897, p-value: 0.3528409148886912

Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders,Age

T-statistic: -2.222726686705267, p-value: 0.026946117510749695

Which case does Magnesium taken with caution and the dose should be adjusted ?_Mal-nutrition cases,Age

T-statistic: 1.9935413641205337, p-value: 0.047067045988687266

Which case does Magnesium taken with caution and the dose should be adjusted ?_More than one answer is true,Age

T-statistic: 0.1000520129697844, p-value: 0.9203668811154312

Can Large doses of vitamin D induce severe depletion of Mg ?_False,Age

T-statistic: 3.2227429662184175, p-value: 0.0014030466996489428

Can Large doses of vitamin D induce severe depletion of Mg ?_True,Age

T-statistic: -3.2227429662184175, p-value: 0.0014030466996489428

Is Magnesium safe for pregnant in Eclampsia cases ?_0.0,Age

T-statistic: -0.6888280355574751, p-value: 0.4914401287515072

Is Magnesium safe for pregnant in Eclampsia cases ?_1.0,Age

T-statistic: 0.6888280355574751, p-value: 0.4914401287515072

What is the side effect behind consuming Magnesium supplements for long term ?_All of above,Age

T-statistic: 1.5095427498265956, p-value: 0.13216571210072334

What is the side effect behind consuming Magnesium supplements for long term ?_Dihherhea,Age

T-statistic: -2.952590994295596, p-value: 0.003388841186331362

What is the side effect behind consuming Magnesium supplements for long term ?_Low blood pressure,Age

T-statistic: 1.6455316737363854, p-value: 0.1008607999171182

What is the side effect behind consuming Magnesium supplements for long term ?_Muscle weakness,Age

T-statistic: 0.5143077649326033, p-value: 0.6073986108053226

What is the side effect behind consuming Magnesium supplements for long term ?_Sleepness,Age

T-statistic: -0.3079013344392838, p-value: 0.7583615489313137

Why do you think the reasons behind side effects of using Magnesium ?_Lack of instruction about administration from health care provider,Age

T-statistic: 0.8707605121721913, p-value: 0.3845501499185132

Why do you think the reasons behind side effects of using Magnesium ?_Lack of sufficient knowledge,Age

T-statistic: 2.3588210327291734, p-value: 0.018945360985937226

Why do you think the reasons behind side effects of using Magnesium ?_Misuse of Magnesium ( improper dose .. ),Age

T-statistic: -2.282666088232517, p-value: 0.023118310641447863

Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true,Age

T-statistic: -0.32422401131675654, p-value: 0.7459843137490025

Do you recommend others by using Magnesium Supplement regularly ? _No,Age

T-statistic: -0.7088011611769709, p-value: 0.478973773818815

Do you recommend others by using Magnesium Supplement regularly ? _Yes,Age

T-statistic: 0.7088011611769709, p-value: 0.478973773818815

The P value calulated for all questions and Years of Experience column¶

In [88]:
columns_to_iterate = dc_df.columns[3:]
for column in columns_to_iterate:
    group1 = dc_df[dc_df[column]]['Years of Experience ']
    group2 = dc_df[~dc_df[column]]['Years of Experience ']
    t_statistic, p_value = stats.ttest_ind(group1, group2)
    print(f"\n{column},years of experience")
    print(f"\nT-statistic: {t_statistic}, p-value: {p_value}")
Your Gender _Female,years of experience

T-statistic: -0.7235917949009195, p-value: 0.46985507952026906

Your Gender _Male,years of experience

T-statistic: 0.7235917949009195, p-value: 0.46985507952026906

Educational Level _Bachelor's Degree,years of experience

T-statistic: -3.4870121033129764, p-value: 0.000558090393091366

Educational Level _Master's Degree,years of experience

T-statistic: 1.3151602381532888, p-value: 0.1894156477326787

Educational Level _PHD degree,years of experience

T-statistic: 3.7247456498593285, p-value: 0.0002317414234419668

Are you aware of the potential health benefits of Magnesium supplements?_No,years of experience

T-statistic: 1.979552241070833, p-value: 0.04862688705103311

Are you aware of the potential health benefits of Magnesium supplements?_Yes,years of experience

T-statistic: -1.979552241070833, p-value: 0.04862688705103311

Where do you get the knowledge about Magnesium benefits ?_Magnesium supplements Labels,years of experience

T-statistic: 0.5794383621576619, p-value: 0.5627088996053131

Where do you get the knowledge about Magnesium benefits ?_More than one answer is true,years of experience

T-statistic: -0.980383390131348, p-value: 0.32765165823003417

Where do you get the knowledge about Magnesium benefits ?_Scientific Researches,years of experience

T-statistic: 1.4629158868267338, p-value: 0.14449061221471993

Where do you get the knowledge about Magnesium benefits ?_Self experience,years of experience

T-statistic: -0.15426601464509224, p-value: 0.8774990968006849

Where do you get the knowledge about Magnesium benefits ?_University courses,years of experience

T-statistic: -1.0143119914934173, p-value: 0.3112148314153578

What food is highest in magnesium ?_Chicken & Meat,years of experience

T-statistic: -3.4275925772458704, p-value: 0.0006901292266916372

What food is highest in magnesium ?_Sea Food,years of experience

T-statistic: 0.5797135484946349, p-value: 0.5625235095608963

What food is highest in magnesium ?_Whole grains,years of experience

T-statistic: 2.6134952874737003, p-value: 0.00939372282574437

What are the signs of low magnesium ?_All of above,years of experience

T-statistic: 1.3529620744102002, p-value: 0.1770410765128163

What are the signs of low magnesium ?_Fatigue,years of experience

T-statistic: -2.2171027181611542, p-value: 0.027332006241827925

What are the signs of low magnesium ?_Insomnia,years of experience

T-statistic: 1.2317437579146635, p-value: 0.21896645858362485

What are the signs of low magnesium ?_Mood changes,years of experience

T-statistic: 0.14238094122962733, p-value: 0.886870430313245

What are the signs of low magnesium ?_Muscle spasms,years of experience

T-statistic: -0.12705085649982165, p-value: 0.8989814677926019

What are the health condition does magnesium used for  ?_All of above,years of experience

T-statistic: 2.0921139489324245, p-value: 0.037231131270983896

What are the health condition does magnesium used for  ?_Chronic diseases ( Arrhythmia , diabetes ,..),years of experience

T-statistic: 1.5475184897883474, p-value: 0.12274552039188694

What are the health condition does magnesium used for  ?_Migraine headache,years of experience

T-statistic: -0.7803880260137441, p-value: 0.4357503941351618

What are the health condition does magnesium used for  ?_Muscle cramps,years of experience

T-statistic: -2.0357629887145445, p-value: 0.0426133249212365

What are the health condition does magnesium used for  ?_Power and energy,years of experience

T-statistic: -0.17627801914377686, p-value: 0.8601891651194328

Can magnesium maintained body biological clock balanced ?_False,years of experience

T-statistic: 0.6399366513839332, p-value: 0.522680428961717

Can magnesium maintained body biological clock balanced ?_True,years of experience

T-statistic: -0.6399366513839332, p-value: 0.522680428961717

Does magnesium help with anxiety ?_No,years of experience

T-statistic: -0.17900025534381778, p-value: 0.8580529437325534

Does magnesium help with anxiety ?_Yes,years of experience

T-statistic: 0.17900025534381778, p-value: 0.8580529437325534

What is the main health benefit for Magnesium L-threonate ?_Brain health,years of experience

T-statistic: 1.1526204784911525, p-value: 0.24994291469648677

What is the main health benefit for Magnesium L-threonate ?_Control blood pressure,years of experience

T-statistic: 2.2863245943873873, p-value: 0.022900860046624973

What is the main health benefit for Magnesium L-threonate ?_Heartburn,years of experience

T-statistic: -3.5836020548251146, p-value: 0.00039270719023858525

What is the main health benefit for Magnesium L-threonate ?_More than one answer is correct,years of experience

T-statistic: 0.15152840454791555, p-value: 0.8796562122945272

To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium carbonate,years of experience

T-statistic: 1.00352404008979, p-value: 0.31638078457615737

To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate,years of experience

T-statistic: 0.7034247569930128, p-value: 0.48231232957335035

To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium oxide,years of experience

T-statistic: -1.4944886800995143, p-value: 0.13605217925957538

To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_More than one answer is true,years of experience

T-statistic: -0.03222911932345485, p-value: 0.9743098106257351

Magnesium oxide is best indicated for ?_Constipation,years of experience

T-statistic: 0.11879492995803345, p-value: 0.9055137872405192

Magnesium oxide is best indicated for ?_Depression,years of experience

T-statistic: 1.7233864538639234, p-value: 0.08580306514068775

Magnesium oxide is best indicated for ?_Diarrhea,years of experience

T-statistic: -2.9514624981130932, p-value: 0.0034009085307559216

Magnesium oxide is best indicated for ?_Urinary antiseptic,years of experience

T-statistic: 1.2364848398388046, p-value: 0.21720246411471686

Are you aware about Magnesium supplements toxicity ?
_No,years of experience

T-statistic: 0.9242262244348597, p-value: 0.3560782384336456

Are you aware about Magnesium supplements toxicity ?
_Yes,years of experience

T-statistic: -0.9242262244348597, p-value: 0.3560782384336456

What is the recommended dose of Magnesium supplements that patient needs ?_120 for Female & 220 for Male,years of experience

T-statistic: -2.179502320745721, p-value: 0.030037135983469222

What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male,years of experience

T-statistic: 0.6283383882320616, p-value: 0.5302390442245373

What is the recommended dose of Magnesium supplements that patient needs ?_520 for Female & 620 for Male,years of experience

T-statistic: 1.861843125898514, p-value: 0.06355928704277125

If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours,years of experience

T-statistic: -0.14945995888983485, p-value: 0.8812866521474805

If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Stop Magnesium until doxycyclin course finished,years of experience

T-statistic: -1.6965041068374869, p-value: 0.09078149161925546

If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Taking another choice of antibiotic rather than doxycyclin,years of experience

T-statistic: 2.0793970677345186, p-value: 0.038392068628059196

Which case does Magnesium taken with caution and the dose should be adjusted ?_Gastric discomfort,years of experience

T-statistic: 0.6659903478250923, p-value: 0.5059062380768625

Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders,years of experience

T-statistic: -3.050363575764347, p-value: 0.002480440337132142

Which case does Magnesium taken with caution and the dose should be adjusted ?_Mal-nutrition cases,years of experience

T-statistic: 2.0086896348351764, p-value: 0.04542586002948874

Which case does Magnesium taken with caution and the dose should be adjusted ?_More than one answer is true,years of experience

T-statistic: 1.4629131871640237, p-value: 0.14449135060236265

Can Large doses of vitamin D induce severe depletion of Mg ?_False,years of experience

T-statistic: 3.2410469509344906, p-value: 0.0013187399941733513

Can Large doses of vitamin D induce severe depletion of Mg ?_True,years of experience

T-statistic: -3.2410469509344906, p-value: 0.0013187399941733513

Is Magnesium safe for pregnant in Eclampsia cases ?_0.0,years of experience

T-statistic: 0.08860957143745743, p-value: 0.9294486880602872

Is Magnesium safe for pregnant in Eclampsia cases ?_1.0,years of experience

T-statistic: -0.08860957143745743, p-value: 0.9294486880602872

What is the side effect behind consuming Magnesium supplements for long term ?_All of above,years of experience

T-statistic: 2.7000774625130095, p-value: 0.007308146277660231

What is the side effect behind consuming Magnesium supplements for long term ?_Dihherhea,years of experience

T-statistic: -4.003281402315866, p-value: 7.801009112013629e-05

What is the side effect behind consuming Magnesium supplements for long term ?_Low blood pressure,years of experience

T-statistic: 0.9144814000445851, p-value: 0.3611656347168888

What is the side effect behind consuming Magnesium supplements for long term ?_Muscle weakness,years of experience

T-statistic: 0.9948332967586577, p-value: 0.3205833561667032

What is the side effect behind consuming Magnesium supplements for long term ?_Sleepness,years of experience

T-statistic: 0.08158010778101009, p-value: 0.9350325954198445

Why do you think the reasons behind side effects of using Magnesium ?_Lack of instruction about administration from health care provider,years of experience

T-statistic: 0.8007434290105743, p-value: 0.4238856451929425

Why do you think the reasons behind side effects of using Magnesium ?_Lack of sufficient knowledge,years of experience

T-statistic: 1.448920423720832, p-value: 0.14835770625865138

Why do you think the reasons behind side effects of using Magnesium ?_Misuse of Magnesium ( improper dose .. ),years of experience

T-statistic: -2.955679901413708, p-value: 0.0033560106599916646

Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true,years of experience

T-statistic: 1.0741421971637335, p-value: 0.2835836856886082

Do you recommend others by using Magnesium Supplement regularly ? _No,years of experience

T-statistic: -0.9772202002210088, p-value: 0.3292124184517534

Do you recommend others by using Magnesium Supplement regularly ? _Yes,years of experience

T-statistic: 0.9772202002210088, p-value: 0.3292124184517534
In [89]:
# Assuming df is your DataFrame containing non-boolean variables

# Scatter plot between two non-boolean variables
plt.figure(figsize=(8, 6))
sns.scatterplot(data=df, x='Your Age', y='Years of Experience ')
plt.title('Scatter Plot between Age and Years of Experience ')
plt.xlabel('Age')
plt.ylabel('Years of Experience')
plt.show()

# Pair plot to visualize relationships between all pairs of non-boolean variables
sns.pairplot(df[[ 'Your Age', 'Years of Experience ']])
plt.suptitle('Pair Plot of Non-Boolean Variables', y=1.02)
plt.show()
No description has been provided for this image
No description has been provided for this image
In [90]:
# Scatter plot between a boolean and a non-boolean variable
for column in columns_to_iterate:
    plt.figure()
    plt.pie(dc_df[column].value_counts(), labels=['False', 'True'], autopct='%1.1f%%', startangle=140)
    plt.title(f'Proportion of True and False Values for {column}')
    plt.axis('equal')
    plt.show()
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

The P value calulated for all correct answers and age column¶

In [91]:
# Assuming dc_df is your DataFrame containing the data and selected_columns is the list of selected columns
selected_columns = ['Your Age', 'Years of Experience ',
                    'What food is highest in magnesium ?_Whole grains',
                    'What are the signs of low magnesium ?_All of above',
                    'What are the health condition does magnesium used for  ?_All of above',
                    'Can magnesium maintained body biological clock balanced ?_True', 
                    'Does magnesium help with anxiety ?_Yes', 
                    'What is the main health benefit for Magnesium L-threonate ?_Brain health',
                    'To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate',
                    'Magnesium oxide is best indicated for ?_Constipation', 'What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male', 
                    'If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours',
                    'Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders',
                    'Can Large doses of vitamin D induce severe depletion of Mg ?_True', 'Is Magnesium safe for pregnant in Eclampsia cases ?_1.0',
                    'What is the side effect behind consuming Magnesium supplements for long term ?_All of above', 
                    'Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true']

# Create an empty dictionary to store the results
results = {}

# Iterate over each column
for column in selected_columns:
    # Filter the DataFrame to include only the rows where the answer is true
    correct_answers_df = dc_df[dc_df[column] == True]
    
    # Perform your analysis on the filtered DataFrame
    # For example, you can calculate mean age, median year of experience, etc.
    mean_age = correct_answers_df['Your Age'].mean()
    median_year_of_experience = correct_answers_df['Years of Experience '].median()

    # Perform the t-test
    t_statistic, p_value = stats.ttest_ind(correct_answers_df['Your Age'], correct_answers_df['Years of Experience '])
    
    # Calculate the standard deviation
    age_std = correct_answers_df['Your Age'].std()
    exp_std = correct_answers_df['Years of Experience '].std()
    
    # Store the results in the dictionary
    results[column] = {'mean_age': mean_age, 'median_year_of_experience': median_year_of_experience ,'t_statistic': t_statistic, 'p_value': p_value, 'age_std': age_std, 'exp_std': exp_std}

# Print the results
for column, result in results.items():
    print(f"Column: {column}")
    print(f"Mean Age: {result['mean_age']}")
    print(f"Median Year of Experience: {result['median_year_of_experience']}")
    print(f"t-statistic: {result['t_statistic']}, p-value: {result['p_value']}")
    print(f"Age Standard Deviation: {result['age_std']}")
    print(f"Experience Standard Deviation: {result['exp_std']}")
    print()
    
Column: Your Age
Mean Age: nan
Median Year of Experience: nan
t-statistic: nan, p-value: nan
Age Standard Deviation: nan
Experience Standard Deviation: nan

Column: Years of Experience 
Mean Age: 22.666666666666668
Median Year of Experience: 1.0
t-statistic: 65.00000000000001, p-value: 1.8082615043720467e-14
Age Standard Deviation: 0.816496580927726
Experience Standard Deviation: 0.0

Column: What food is highest in magnesium ?_Whole grains
Mean Age: 35.76543209876543
Median Year of Experience: 9.0
t-statistic: 25.191994114870628, p-value: 3.9869457927294197e-78
Age Standard Deviation: 9.395084752890435
Experience Standard Deviation: 7.78854868914805

Column: What are the signs of low magnesium ?_All of above
Mean Age: 35.44117647058823
Median Year of Experience: 8.5
t-statistic: 9.859320765231507, p-value: 1.3287640559787818e-14
Age Standard Deviation: 10.198607083948422
Experience Standard Deviation: 9.235867461794587

Column: What are the health condition does magnesium used for  ?_All of above
Mean Age: 35.98148148148148
Median Year of Experience: 10.0
t-statistic: 13.22984382075505, p-value: 3.516416722033589e-24
Age Standard Deviation: 9.789271641610293
Experience Standard Deviation: 8.649818327163988

Column: Can magnesium maintained body biological clock balanced ?_True
Mean Age: 34.13214285714286
Median Year of Experience: 8.0
t-statistic: 35.62270302660991, p-value: 7.845882645096947e-146
Age Standard Deviation: 8.39997241723704
Experience Standard Deviation: 7.277837775263455

Column: Does magnesium help with anxiety ?_Yes
Mean Age: 34.63297872340426
Median Year of Experience: 8.0
t-statistic: 27.899090948941325, p-value: 2.0413456873071497e-93
Age Standard Deviation: 9.015635714493087
Experience Standard Deviation: 7.60942849232105

Column: What is the main health benefit for Magnesium L-threonate ?_Brain health
Mean Age: 34.48837209302326
Median Year of Experience: 10.0
t-statistic: 13.632895200524967, p-value: 5.36322355362598e-23
Age Standard Deviation: 8.051536656124528
Experience Standard Deviation: 7.389945580385767

Column: To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate
Mean Age: 34.206896551724135
Median Year of Experience: 10.0
t-statistic: 13.119787151584944, p-value: 1.01131683816486e-18
Age Standard Deviation: 7.032472184419255
Experience Standard Deviation: 6.127343223238719

Column: Magnesium oxide is best indicated for ?_Constipation
Mean Age: 33.06
Median Year of Experience: 10.0
t-statistic: 17.807562432549016, p-value: 1.7477598834891396e-32
Age Standard Deviation: 6.2675386569471225
Experience Standard Deviation: 6.3001133776646085

Column: What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male
Mean Age: 34.525
Median Year of Experience: 8.5
t-statistic: 13.146824754280104, p-value: 1.7710969678506563e-21
Age Standard Deviation: 8.676486054642758
Experience Standard Deviation: 7.0774107970177615

Column: If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours
Mean Age: 34.26086956521739
Median Year of Experience: 8.0
t-statistic: 18.151518720806823, p-value: 3.7294550348190847e-38
Age Standard Deviation: 8.394066836537935
Experience Standard Deviation: 6.948415460258162

Column: Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders
Mean Age: 33.23456790123457
Median Year of Experience: 7.0
t-statistic: 28.772642454665355, p-value: 5.237852917252745e-91
Age Standard Deviation: 8.121395108464009
Experience Standard Deviation: 6.757073333004849

Column: Can Large doses of vitamin D induce severe depletion of Mg ?_True
Mean Age: 33.80276816608997
Median Year of Experience: 8.0
t-statistic: 36.62466879171478, p-value: 1.5184562374805554e-152
Age Standard Deviation: 8.342860758995267
Experience Standard Deviation: 7.127644831088259

Column: Is Magnesium safe for pregnant in Eclampsia cases ?_1.0
Mean Age: 34.60645161290323
Median Year of Experience: 8.0
t-statistic: 23.81760467192576, p-value: 7.889180332809891e-72
Age Standard Deviation: 9.741794265380845
Experience Standard Deviation: 7.968533634124501

Column: What is the side effect behind consuming Magnesium supplements for long term ?_All of above
Mean Age: 36.0
Median Year of Experience: 12.0
t-statistic: 14.153874520045663, p-value: 7.993708999228465e-25
Age Standard Deviation: 8.04606303944871
Experience Standard Deviation: 7.555407422078475

Column: Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true
Mean Age: 34.06140350877193
Median Year of Experience: 9.0
t-statistic: 22.96802819721461, p-value: 5.045343953343292e-61
Age Standard Deviation: 7.804338579764348
Experience Standard Deviation: 7.242425334940253

C:\Users\samir\miniconda3\Lib\site-packages\scipy\stats\_axis_nan_policy.py:523: RuntimeWarning: Precision loss occurred in moment calculation due to catastrophic cancellation. This occurs when the data are nearly identical. Results may be unreliable.
  res = hypotest_fun_out(*samples, **kwds)
In [92]:
selected_columns = ['Your Age', 'Years of Experience ',
                    'What food is highest in magnesium ?_Whole grains',
                    'What are the signs of low magnesium ?_All of above',
                    'What are the health condition does magnesium used for  ?_All of above',
                    'Can magnesium maintained body biological clock balanced ?_True', 
                    'Does magnesium help with anxiety ?_Yes', 
                    'What is the main health benefit for Magnesium L-threonate ?_Brain health',
                    'To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate',
                    'Magnesium oxide is best indicated for ?_Constipation', 
                    'What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male', 
                    'If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours',
                    'Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders',
                    'Can Large doses of vitamin D induce severe depletion of Mg ?_True', 
                    'Is Magnesium safe for pregnant in Eclampsia cases ?_1.0',
                    'What is the side effect behind consuming Magnesium supplements for long term ?_All of above', 
                    'Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true']

# Select the columns from dc_df based on the selected_column names
selected_df = dc_df[selected_columns]

# Generate descriptive statistics for the selected columns
description = selected_df.describe()

# Print the descriptive statistics
print(description)
         Your Age  Years of Experience 
count  316.000000            316.000000
mean    34.268987             10.566456
std      8.537896              7.354861
min     22.000000              1.000000
25%     28.000000              5.000000
50%     31.000000              8.000000
75%     40.000000             15.000000
max     60.000000             32.000000

Here you will find simple analysis and the count for each column in details that is easily understandable¶

In [93]:

Count for all columns

Column: Your Age
Your Age
29    31
30    25
28    23
31    19
26    18
27    16
25    15
33    15
34    15
40    10
32    10
36     9
35     9
24     9
41     8
39     8
42     7
45     7
52     6
46     6
44     6
38     4
43     4
49     3
47     3
53     3
22     3
50     3
23     3
54     3
37     3
55     2
48     2
56     2
59     2
51     1
57     1
58     1
60     1
Name: count, dtype: int64

Column: Years of Experience 
Years of Experience 
6     30
4     27
5     26
7     19
3     19
8     18
2     17
12    15
9     14
11    13
10    13
13    11
22     8
20     8
19     8
15     8
18     7
14     7
23     7
1      6
24     5
25     5
16     5
17     4
32     3
21     3
27     3
29     2
26     2
30     1
31     1
28     1
Name: count, dtype: int64

Column: What food is highest in magnesium ?_Whole grains
What food is highest in magnesium ?_Whole grains
True     162
False    154
Name: count, dtype: int64

Column: What are the signs of low magnesium ?_All of above
What are the signs of low magnesium ?_All of above
False    282
True      34
Name: count, dtype: int64

Column: What are the health condition does magnesium used for  ?_All of above
What are the health condition does magnesium used for  ?_All of above
False    262
True      54
Name: count, dtype: int64

Column: Can magnesium maintained body biological clock balanced ?_True
Can magnesium maintained body biological clock balanced ?_True
True     280
False     36
Name: count, dtype: int64

Column: Does magnesium help with anxiety ?_Yes
Does magnesium help with anxiety ?_Yes
True     188
False    128
Name: count, dtype: int64

Column: What is the main health benefit for Magnesium L-threonate ?_Brain health
What is the main health benefit for Magnesium L-threonate ?_Brain health
False    273
True      43
Name: count, dtype: int64

Column: To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate
To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate
False    287
True      29
Name: count, dtype: int64

Column: Magnesium oxide is best indicated for ?_Constipation
Magnesium oxide is best indicated for ?_Constipation
False    266
True      50
Name: count, dtype: int64

Column: What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male
What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male
False    276
True      40
Name: count, dtype: int64

Column: If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours
If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours
False    247
True      69
Name: count, dtype: int64

Column: Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders
Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders
True     162
False    154
Name: count, dtype: int64

Column: Can Large doses of vitamin D induce severe depletion of Mg ?_True
Can Large doses of vitamin D induce severe depletion of Mg ?_True
True     289
False     27
Name: count, dtype: int64

Column: Is Magnesium safe for pregnant in Eclampsia cases ?_1.0
Is Magnesium safe for pregnant in Eclampsia cases ?_1.0
False    161
True     155
Name: count, dtype: int64

Column: What is the side effect behind consuming Magnesium supplements for long term ?_All of above
What is the side effect behind consuming Magnesium supplements for long term ?_All of above
False    269
True      47
Name: count, dtype: int64

Column: Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true
Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true
False    202
True     114
Name: count, dtype: int64

In [94]:

Percentage of correct answer for each Question

Column: What food is highest in magnesium ?_Whole grains
Percentage of True values: 51.27%

Column: What are the signs of low magnesium ?_All of above
Percentage of True values: 10.76%

Column: What are the health condition does magnesium used for  ?_All of above
Percentage of True values: 17.09%

Column: Can magnesium maintained body biological clock balanced ?_True
Percentage of True values: 88.61%

Column: Does magnesium help with anxiety ?_Yes
Percentage of True values: 59.49%

Column: What is the main health benefit for Magnesium L-threonate ?_Brain health
Percentage of True values: 13.61%

Column: To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate
Percentage of True values: 9.18%

Column: Magnesium oxide is best indicated for ?_Constipation
Percentage of True values: 15.82%

Column: What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male
Percentage of True values: 12.66%

Column: If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours
Percentage of True values: 21.84%

Column: Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders
Percentage of True values: 51.27%

Column: Can Large doses of vitamin D induce severe depletion of Mg ?_True
Percentage of True values: 91.46%

Column: Is Magnesium safe for pregnant in Eclampsia cases ?_1.0
Percentage of True values: 49.05%

Column: What is the side effect behind consuming Magnesium supplements for long term ?_All of above
Percentage of True values: 14.87%

Column: Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true
Percentage of True values: 36.08%

In [95]:

Group by education level and calculate the sum of True values for each boolean column

                                                                                                       Your Age  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree             
False                                False                              True                               1020   
                                     True                               False                              6213   
True                                 False                              False                              3596   

                                                                                                       Years of Experience   \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                         
False                                False                              True                                            393   
                                     True                               False                                          1987   
True                                 False                              False                                           959   

                                                                                                       What food is highest in magnesium ?_Whole grains  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                     
False                                False                              True                                                                         15   
                                     True                               False                                                                        95   
True                                 False                              False                                                                        52   

                                                                                                       What are the signs of low magnesium ?_All of above  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                       
False                                False                              True                                                                           3    
                                     True                               False                                                                         23    
True                                 False                              False                                                                          8    

                                                                                                       What are the health condition does magnesium used for  ?_All of above  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                          
False                                False                              True                                                                           5                       
                                     True                               False                                                                         36                       
True                                 False                              False                                                                         13                       

                                                                                                       Can magnesium maintained body biological clock balanced ?_True  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                   
False                                False                              True                                                                          22                
                                     True                               False                                                                        157                
True                                 False                              False                                                                        101                

                                                                                                       Does magnesium help with anxiety ?_Yes  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                           
False                                False                              True                                                               20   
                                     True                               False                                                             102   
True                                 False                              False                                                              66   

                                                                                                       What is the main health benefit for Magnesium L-threonate ?_Brain health  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                             
False                                False                              True                                                                           6                          
                                     True                               False                                                                         24                          
True                                 False                              False                                                                         13                          

                                                                                                       To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                                                                         
False                                False                              True                                                                           4                                                                      
                                     True                               False                                                                         20                                                                      
True                                 False                              False                                                                          5                                                                      

                                                                                                       Magnesium oxide is best indicated for ?_Constipation  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                         
False                                False                              True                                                                           5      
                                     True                               False                                                                         34      
True                                 False                              False                                                                         11      

                                                                                                       What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                                                             
False                                False                              True                                                                           7                                                          
                                     True                               False                                                                         24                                                          
True                                 False                              False                                                                          9                                                          

                                                                                                       If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                                                                                                                             
False                                False                              True                                                                           6                                                                                                                          
                                     True                               False                                                                         41                                                                                                                          
True                                 False                              False                                                                         22                                                                                                                          

                                                                                                       Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                                                    
False                                False                              True                                                                          13                                                 
                                     True                               False                                                                         87                                                 
True                                 False                              False                                                                         62                                                 

                                                                                                       Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                      
False                                False                              True                                                                          19                   
                                     True                               False                                                                        165                   
True                                 False                              False                                                                        105                   

                                                                                                       Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                            
False                                False                              True                                                                          15         
                                     True                               False                                                                         85         
True                                 False                              False                                                                         55         

                                                                                                       What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                                                
False                                False                              True                                                                           5                                             
                                     True                               False                                                                         32                                             
True                                 False                              False                                                                         10                                             

                                                                                                       Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                                                      
False                                False                              True                                                                           8                                                   
                                     True                               False                                                                         76                                                   
True                                 False                              False                                                                         30                                                   
In [96]:

Group by education level and calculate the percentage of True values for each boolean column

                                                                                                          Your Age  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                
False                                False                              True                           4080.000000   
                                     True                               False                          3451.666667   
True                                 False                              False                          3239.639640   

                                                                                                       Years of Experience   \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                         
False                                False                              True                                    1572.000000   
                                     True                               False                                   1103.888889   
True                                 False                              False                                    863.963964   

                                                                                                       What food is highest in magnesium ?_Whole grains  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                     
False                                False                              True                                                                  60.000000   
                                     True                               False                                                                 52.777778   
True                                 False                              False                                                                 46.846847   

                                                                                                       What are the signs of low magnesium ?_All of above  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                       
False                                False                              True                                                                   12.000000    
                                     True                               False                                                                  12.777778    
True                                 False                              False                                                                   7.207207    

                                                                                                       What are the health condition does magnesium used for  ?_All of above  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                          
False                                False                              True                                                                   20.000000                       
                                     True                               False                                                                  20.000000                       
True                                 False                              False                                                                  11.711712                       

                                                                                                       Can magnesium maintained body biological clock balanced ?_True  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                   
False                                False                              True                                                                   88.000000                
                                     True                               False                                                                  87.222222                
True                                 False                              False                                                                  90.990991                

                                                                                                       Does magnesium help with anxiety ?_Yes  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                           
False                                False                              True                                                        80.000000   
                                     True                               False                                                       56.666667   
True                                 False                              False                                                       59.459459   

                                                                                                       What is the main health benefit for Magnesium L-threonate ?_Brain health  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                             
False                                False                              True                                                                   24.000000                          
                                     True                               False                                                                  13.333333                          
True                                 False                              False                                                                  11.711712                          

                                                                                                       To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                                                                         
False                                False                              True                                                                   16.000000                                                                      
                                     True                               False                                                                  11.111111                                                                      
True                                 False                              False                                                                   4.504505                                                                      

                                                                                                       Magnesium oxide is best indicated for ?_Constipation  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                         
False                                False                              True                                                                   20.000000      
                                     True                               False                                                                  18.888889      
True                                 False                              False                                                                   9.909910      

                                                                                                       What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                                                             
False                                False                              True                                                                   28.000000                                                          
                                     True                               False                                                                  13.333333                                                          
True                                 False                              False                                                                   8.108108                                                          

                                                                                                       If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                                                                                                                             
False                                False                              True                                                                   24.000000                                                                                                                          
                                     True                               False                                                                  22.777778                                                                                                                          
True                                 False                              False                                                                  19.819820                                                                                                                          

                                                                                                       Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                                                    
False                                False                              True                                                                   52.000000                                                 
                                     True                               False                                                                  48.333333                                                 
True                                 False                              False                                                                  55.855856                                                 

                                                                                                       Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                      
False                                False                              True                                                                   76.000000                   
                                     True                               False                                                                  91.666667                   
True                                 False                              False                                                                  94.594595                   

                                                                                                       Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                            
False                                False                              True                                                                   60.000000         
                                     True                               False                                                                  47.222222         
True                                 False                              False                                                                  49.549550         

                                                                                                       What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                                                
False                                False                              True                                                                   20.000000                                             
                                     True                               False                                                                  17.777778                                             
True                                 False                              False                                                                   9.009009                                             

                                                                                                       Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
Educational Level _Bachelor's Degree Educational Level _Master's Degree Educational Level _PHD degree                                                                                                      
False                                False                              True                                                                   32.000000                                                   
                                     True                               False                                                                  42.222222                                                   
True                                 False                              False                                                                  27.027027                                                   
In [97]:

creating new table with this columns inside ,you can see a small sample of the columns

    Your Gender  Educational Level   Years of Experience   \
0         Female    Master's Degree                    12   
1         Female  Bachelor's Degree                    15   
2           Male    Master's Degree                    20   
3           Male    Master's Degree                     2   
4           Male    Master's Degree                    13   
..           ...                ...                   ...   
315         Male  Bachelor's Degree                     3   
316         Male    Master's Degree                     4   
317         Male    Master's Degree                    26   
318       Female  Bachelor's Degree                     8   
319       Female  Bachelor's Degree                     8   

    Where do you get the knowledge about Magnesium benefits ?  Your Age  \
0                                      Self experience               35   
1                         Magnesium supplements Labels               42   
2                                      Self experience               44   
3                                      Self experience               25   
4                         More than one answer is true               45   
..                                                 ...              ...   
315                       Magnesium supplements Labels               25   
316                       More than one answer is true               26   
317                       Magnesium supplements Labels               46   
318                                    Self experience               31   
319                                 University courses               30   

     What food is highest in magnesium ?_Whole grains  \
0                                               False   
1                                                True   
2                                               False   
3                                               False   
4                                                True   
..                                                ...   
315                                             False   
316                                              True   
317                                              True   
318                                              True   
319                                              True   

     What are the signs of low magnesium ?_All of above  \
0                                                False    
1                                                False    
2                                                False    
3                                                False    
4                                                False    
..                                                 ...    
315                                              False    
316                                              False    
317                                              False    
318                                              False    
319                                              False    

     What are the health condition does magnesium used for  ?_All of above  \
0                                                False                       
1                                                False                       
2                                                False                       
3                                                False                       
4                                                False                       
..                                                 ...                       
315                                              False                       
316                                               True                       
317                                              False                       
318                                              False                       
319                                              False                       

     Can magnesium maintained body biological clock balanced ?_True  \
0                                                False                
1                                                False                
2                                                 True                
3                                                 True                
4                                                 True                
..                                                 ...                
315                                               True                
316                                               True                
317                                               True                
318                                               True                
319                                               True                

     Does magnesium help with anxiety ?_Yes  \
0                                     False   
1                                     False   
2                                     False   
3                                     False   
4                                     False   
..                                      ...   
315                                   False   
316                                   False   
317                                   False   
318                                   False   
319                                    True   

     What is the main health benefit for Magnesium L-threonate ?_Brain health  \
0                                                False                          
1                                                 True                          
2                                                False                          
3                                                 True                          
4                                                False                          
..                                                 ...                          
315                                               True                          
316                                              False                          
317                                              False                          
318                                              False                          
319                                               True                          

     To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
0                                                False                                                                      
1                                                False                                                                      
2                                                False                                                                      
3                                                False                                                                      
4                                                 True                                                                      
..                                                 ...                                                                      
315                                               True                                                                      
316                                              False                                                                      
317                                              False                                                                      
318                                              False                                                                      
319                                              False                                                                      

     Magnesium oxide is best indicated for ?_Constipation  \
0                                                 True      
1                                                 True      
2                                                False      
3                                                False      
4                                                False      
..                                                 ...      
315                                               True      
316                                              False      
317                                              False      
318                                              False      
319                                              False      

     What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
0                                                 True                                                          
1                                                False                                                          
2                                                False                                                          
3                                                False                                                          
4                                                False                                                          
..                                                 ...                                                          
315                                              False                                                          
316                                              False                                                          
317                                              False                                                          
318                                              False                                                          
319                                              False                                                          

     If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
0                                                False                                                                                                                          
1                                                False                                                                                                                          
2                                                False                                                                                                                          
3                                                 True                                                                                                                          
4                                                False                                                                                                                          
..                                                 ...                                                                                                                          
315                                               True                                                                                                                          
316                                              False                                                                                                                          
317                                              False                                                                                                                          
318                                              False                                                                                                                          
319                                               True                                                                                                                          

     Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
0                                                 True                                                 
1                                                False                                                 
2                                                 True                                                 
3                                                 True                                                 
4                                                 True                                                 
..                                                 ...                                                 
315                                               True                                                 
316                                               True                                                 
317                                              False                                                 
318                                              False                                                 
319                                               True                                                 

     Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
0                                                 True                   
1                                                 True                   
2                                                 True                   
3                                                 True                   
4                                                 True                   
..                                                 ...                   
315                                               True                   
316                                               True                   
317                                               True                   
318                                               True                   
319                                               True                   

     Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
0                                                False         
1                                                False         
2                                                False         
3                                                False         
4                                                False         
..                                                 ...         
315                                              False         
316                                              False         
317                                              False         
318                                              False         
319                                              False         

     What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
0                                                False                                             
1                                                False                                             
2                                                False                                             
3                                                False                                             
4                                                False                                             
..                                                 ...                                             
315                                              False                                             
316                                              False                                             
317                                              False                                             
318                                              False                                             
319                                              False                                             

     Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
0                                                False                                                   
1                                                False                                                   
2                                                False                                                   
3                                                False                                                   
4                                                False                                                   
..                                                 ...                                                   
315                                               True                                                   
316                                               True                                                   
317                                              False                                                   
318                                               True                                                   
319                                               True                                                   

[316 rows x 20 columns]
In [98]:

Group by education level and calculate the sum of True values for each boolean column

                   

                    What food is highest in magnesium ?_Whole grains  \
Educational Level                                                      
Bachelor's Degree                                                 52   
Master's Degree                                                   95   
PHD degree                                                        15   

                    What are the signs of low magnesium ?_All of above  \
Educational Level                                                        
Bachelor's Degree                                                   8    
Master's Degree                                                    23    
PHD degree                                                          3    

                    What are the health condition does magnesium used for  ?_All of above  \
Educational Level                                                                           
Bachelor's Degree                                                  13                       
Master's Degree                                                    36                       
PHD degree                                                          5                       

                    Can magnesium maintained body biological clock balanced ?_True  \
Educational Level                                                                    
Bachelor's Degree                                                 101                
Master's Degree                                                   157                
PHD degree                                                         22                

                    Does magnesium help with anxiety ?_Yes  \
Educational Level                                            
Bachelor's Degree                                       66   
Master's Degree                                        102   
PHD degree                                              20   

                    What is the main health benefit for Magnesium L-threonate ?_Brain health  \
Educational Level                                                                              
Bachelor's Degree                                                  13                          
Master's Degree                                                    24                          
PHD degree                                                          6                          

                    To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
Educational Level                                                                                                                          
Bachelor's Degree                                                   5                                                                      
Master's Degree                                                    20                                                                      
PHD degree                                                          4                                                                      

                    Magnesium oxide is best indicated for ?_Constipation  \
Educational Level                                                          
Bachelor's Degree                                                  11      
Master's Degree                                                    34      
PHD degree                                                          5      

                    What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
Educational Level                                                                                                              
Bachelor's Degree                                                   9                                                          
Master's Degree                                                    24                                                          
PHD degree                                                          7                                                          

                    If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
Educational Level                                                                                                                                                                              
Bachelor's Degree                                                  22                                                                                                                          
Master's Degree                                                    41                                                                                                                          
PHD degree                                                          6                                                                                                                          

                    Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
Educational Level                                                                                                     
Bachelor's Degree                                                  62                                                 
Master's Degree                                                    87                                                 
PHD degree                                                         13                                                 

                    Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
Educational Level                                                                       
Bachelor's Degree                                                 105                   
Master's Degree                                                   165                   
PHD degree                                                         19                   

                    Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
Educational Level                                                             
Bachelor's Degree                                                  55         
Master's Degree                                                    85         
PHD degree                                                         15         

                    What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
Educational Level                                                                                                 
Bachelor's Degree                                                  10                                             
Master's Degree                                                    32                                             
PHD degree                                                          5                                             

                    Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
Educational Level                                                                                                       
Bachelor's Degree                                                  30                                                   
Master's Degree                                                    76                                                   
PHD degree                                                          8                                                   
Data has been written to grouped_data.xlsx
In [99]:

Group by education level and calculate the percentage of True values for each boolean column

                      

                    What food is highest in magnesium ?_Whole grains  \
Educational Level                                                      
Bachelor's Degree                                          46.846847   
Master's Degree                                            52.777778   
PHD degree                                                 60.000000   

                    What are the signs of low magnesium ?_All of above  \
Educational Level                                                        
Bachelor's Degree                                            7.207207    
Master's Degree                                             12.777778    
PHD degree                                                  12.000000    

                    What are the health condition does magnesium used for  ?_All of above  \
Educational Level                                                                           
Bachelor's Degree                                           11.711712                       
Master's Degree                                             20.000000                       
PHD degree                                                  20.000000                       

                    Can magnesium maintained body biological clock balanced ?_True  \
Educational Level                                                                    
Bachelor's Degree                                           90.990991                
Master's Degree                                             87.222222                
PHD degree                                                  88.000000                

                    Does magnesium help with anxiety ?_Yes  \
Educational Level                                            
Bachelor's Degree                                59.459459   
Master's Degree                                  56.666667   
PHD degree                                       80.000000   

                    What is the main health benefit for Magnesium L-threonate ?_Brain health  \
Educational Level                                                                              
Bachelor's Degree                                           11.711712                          
Master's Degree                                             13.333333                          
PHD degree                                                  24.000000                          

                    To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
Educational Level                                                                                                                          
Bachelor's Degree                                            4.504505                                                                      
Master's Degree                                             11.111111                                                                      
PHD degree                                                  16.000000                                                                      

                    Magnesium oxide is best indicated for ?_Constipation  \
Educational Level                                                          
Bachelor's Degree                                            9.909910      
Master's Degree                                             18.888889      
PHD degree                                                  20.000000      

                    What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
Educational Level                                                                                                              
Bachelor's Degree                                            8.108108                                                          
Master's Degree                                             13.333333                                                          
PHD degree                                                  28.000000                                                          

                    If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
Educational Level                                                                                                                                                                              
Bachelor's Degree                                           19.819820                                                                                                                          
Master's Degree                                             22.777778                                                                                                                          
PHD degree                                                  24.000000                                                                                                                          

                    Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
Educational Level                                                                                                     
Bachelor's Degree                                           55.855856                                                 
Master's Degree                                             48.333333                                                 
PHD degree                                                  52.000000                                                 

                    Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
Educational Level                                                                       
Bachelor's Degree                                           94.594595                   
Master's Degree                                             91.666667                   
PHD degree                                                  76.000000                   

                    Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
Educational Level                                                             
Bachelor's Degree                                           49.549550         
Master's Degree                                             47.222222         
PHD degree                                                  60.000000         

                    What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
Educational Level                                                                                                 
Bachelor's Degree                                            9.009009                                             
Master's Degree                                             17.777778                                             
PHD degree                                                  20.000000                                             

                    Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
Educational Level                                                                                                       
Bachelor's Degree                                           27.027027                                                   
Master's Degree                                             42.222222                                                   
PHD degree                                                  32.000000                                                   
In [100]:

count for all the columns in the new table

Column: Your Gender 
Your Gender 
Female    227
Male       89
Name: count, dtype: int64

Column: Educational Level 
Educational Level 
Master's Degree      180
Bachelor's Degree    111
PHD degree            25
Name: count, dtype: int64



Column: Where do you get the knowledge about Magnesium benefits ?
Where do you get the knowledge about Magnesium benefits ?
Scientific Researches           91
University courses              84
More than one answer is true    57
Magnesium supplements Labels    50
Self experience                 34
Name: count, dtype: int64



Column: What food is highest in magnesium ?_Whole grains
What food is highest in magnesium ?_Whole grains
True     162
False    154
Name: count, dtype: int64

Column: What are the signs of low magnesium ?_All of above
What are the signs of low magnesium ?_All of above
False    282
True      34
Name: count, dtype: int64

Column: What are the health condition does magnesium used for  ?_All of above
What are the health condition does magnesium used for  ?_All of above
False    262
True      54
Name: count, dtype: int64

Column: Can magnesium maintained body biological clock balanced ?_True
Can magnesium maintained body biological clock balanced ?_True
True     280
False     36
Name: count, dtype: int64

Column: Does magnesium help with anxiety ?_Yes
Does magnesium help with anxiety ?_Yes
True     188
False    128
Name: count, dtype: int64

Column: What is the main health benefit for Magnesium L-threonate ?_Brain health
What is the main health benefit for Magnesium L-threonate ?_Brain health
False    273
True      43
Name: count, dtype: int64

Column: To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate
To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate
False    287
True      29
Name: count, dtype: int64

Column: Magnesium oxide is best indicated for ?_Constipation
Magnesium oxide is best indicated for ?_Constipation
False    266
True      50
Name: count, dtype: int64

Column: What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male
What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male
False    276
True      40
Name: count, dtype: int64

Column: If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours
If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours
False    247
True      69
Name: count, dtype: int64

Column: Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders
Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders
True     162
False    154
Name: count, dtype: int64

Column: Can Large doses of vitamin D induce severe depletion of Mg ?_True
Can Large doses of vitamin D induce severe depletion of Mg ?_True
True     289
False     27
Name: count, dtype: int64

Column: Is Magnesium safe for pregnant in Eclampsia cases ?_1.0
Is Magnesium safe for pregnant in Eclampsia cases ?_1.0
False    161
True     155
Name: count, dtype: int64

Column: What is the side effect behind consuming Magnesium supplements for long term ?_All of above
What is the side effect behind consuming Magnesium supplements for long term ?_All of above
False    269
True      47
Name: count, dtype: int64

Column: Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true
Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true
False    202
True     114
Name: count, dtype: int64

In [101]:

Group by education level and calculate the sum of False values for each boolean column

                   

                    What food is highest in magnesium ?_Whole grains  \
Educational Level                                                      
Bachelor's Degree                                                 59   
Master's Degree                                                   85   
PHD degree                                                        10   

                    What are the signs of low magnesium ?_All of above  \
Educational Level                                                        
Bachelor's Degree                                                 103    
Master's Degree                                                   157    
PHD degree                                                         22    

                    What are the health condition does magnesium used for  ?_All of above  \
Educational Level                                                                           
Bachelor's Degree                                                  98                       
Master's Degree                                                   144                       
PHD degree                                                         20                       

                    Can magnesium maintained body biological clock balanced ?_True  \
Educational Level                                                                    
Bachelor's Degree                                                  10                
Master's Degree                                                    23                
PHD degree                                                          3                

                    Does magnesium help with anxiety ?_Yes  \
Educational Level                                            
Bachelor's Degree                                       45   
Master's Degree                                         78   
PHD degree                                               5   

                    What is the main health benefit for Magnesium L-threonate ?_Brain health  \
Educational Level                                                                              
Bachelor's Degree                                                  98                          
Master's Degree                                                   156                          
PHD degree                                                         19                          

                    To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
Educational Level                                                                                                                          
Bachelor's Degree                                                 106                                                                      
Master's Degree                                                   160                                                                      
PHD degree                                                         21                                                                      

                    Magnesium oxide is best indicated for ?_Constipation  \
Educational Level                                                          
Bachelor's Degree                                                 100      
Master's Degree                                                   146      
PHD degree                                                         20      

                    What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
Educational Level                                                                                                              
Bachelor's Degree                                                 102                                                          
Master's Degree                                                   156                                                          
PHD degree                                                         18                                                          

                    If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
Educational Level                                                                                                                                                                              
Bachelor's Degree                                                  89                                                                                                                          
Master's Degree                                                   139                                                                                                                          
PHD degree                                                         19                                                                                                                          

                    Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
Educational Level                                                                                                     
Bachelor's Degree                                                  49                                                 
Master's Degree                                                    93                                                 
PHD degree                                                         12                                                 

                    Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
Educational Level                                                                       
Bachelor's Degree                                                   6                   
Master's Degree                                                    15                   
PHD degree                                                          6                   

                    Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
Educational Level                                                             
Bachelor's Degree                                                  56         
Master's Degree                                                    95         
PHD degree                                                         10         

                    What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
Educational Level                                                                                                 
Bachelor's Degree                                                 101                                             
Master's Degree                                                   148                                             
PHD degree                                                         20                                             

                    Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
Educational Level                                                                                                       
Bachelor's Degree                                                  81                                                   
Master's Degree                                                   104                                                   
PHD degree                                                         17                                                   
In [102]:

Group by education level and calculate the sum of True values for each boolean column

             
              What food is highest in magnesium ?_Whole grains  \
Your Gender                                                      
Female                                                     115   
Male                                                        47   

              What are the signs of low magnesium ?_All of above  \
Your Gender                                                        
Female                                                       25    
Male                                                          9    

              What are the health condition does magnesium used for  ?_All of above  \
Your Gender                                                                           
Female                                                       36                       
Male                                                         18                       

              Can magnesium maintained body biological clock balanced ?_True  \
Your Gender                                                                    
Female                                                      204                
Male                                                         76                

              Does magnesium help with anxiety ?_Yes  \
Your Gender                                            
Female                                           138   
Male                                              50   

              What is the main health benefit for Magnesium L-threonate ?_Brain health  \
Your Gender                                                                              
Female                                                       28                          
Male                                                         15                          

              To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
Your Gender                                                                                                                          
Female                                                       18                                                                      
Male                                                         11                                                                      

              Magnesium oxide is best indicated for ?_Constipation  \
Your Gender                                                          
Female                                                       31      
Male                                                         19      

              What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
Your Gender                                                                                                              
Female                                                       25                                                          
Male                                                         15                                                          

              If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
Your Gender                                                                                                                                                                              
Female                                                       45                                                                                                                          
Male                                                         24                                                                                                                          

              Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
Your Gender                                                                                                     
Female                                                      115                                                 
Male                                                         47                                                 

              Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
Your Gender                                                                       
Female                                                      207                   
Male                                                         82                   

              Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
Your Gender                                                             
Female                                                      120         
Male                                                         35         

              What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
Your Gender                                                                                                 
Female                                                       33                                             
Male                                                         14                                             

              Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
Your Gender                                                                                                       
Female                                                       79                                                   
Male                                                         35                                                   
In [103]:
grouped_df_false = new_df.groupby('Your Gender ')[selected_columns].apply(lambda x: (~x).sum())

# Print the grouped DataFrame
print(grouped_df_false)
excel_file_path_false = "gender_false_data.xlsx"

# Write the grouped DataFrame to an Excel file
#grouped_df_false.to_excel(excel_file_path_false)

#print("Data has been written to", excel_file_path_false)
              

              What food is highest in magnesium ?_Whole grains  \
Your Gender                                                      
Female                                                     112   
Male                                                        42   

              What are the signs of low magnesium ?_All of above  \
Your Gender                                                        
Female                                                      202    
Male                                                         80    

              What are the health condition does magnesium used for  ?_All of above  \
Your Gender                                                                           
Female                                                      191                       
Male                                                         71                       

              Can magnesium maintained body biological clock balanced ?_True  \
Your Gender                                                                    
Female                                                       23                
Male                                                         13                

              Does magnesium help with anxiety ?_Yes  \
Your Gender                                            
Female                                            89   
Male                                              39   

              What is the main health benefit for Magnesium L-threonate ?_Brain health  \
Your Gender                                                                              
Female                                                      199                          
Male                                                         74                          

              To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
Your Gender                                                                                                                          
Female                                                      209                                                                      
Male                                                         78                                                                      

              Magnesium oxide is best indicated for ?_Constipation  \
Your Gender                                                          
Female                                                      196      
Male                                                         70      

              What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
Your Gender                                                                                                              
Female                                                      202                                                          
Male                                                         74                                                          

              If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
Your Gender                                                                                                                                                                              
Female                                                      182                                                                                                                          
Male                                                         65                                                                                                                          

              Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
Your Gender                                                                                                     
Female                                                      112                                                 
Male                                                         42                                                 

              Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
Your Gender                                                                       
Female                                                       20                   
Male                                                          7                   

              Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
Your Gender                                                             
Female                                                      107         
Male                                                         54         

              What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
Your Gender                                                                                                 
Female                                                      194                                             
Male                                                         75                                             

              Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
Your Gender                                                                                                       
Female                                                      148                                                   
Male                                                         54                                                   
In [104]:
# Group by education level and calculate the sum of True values for each boolean column
grouped_df = new_df.groupby('Where do you get the knowledge about Magnesium benefits ?')[selected_columns].sum()

# Print the grouped DataFrame
print(grouped_df)

# Specify the file path where you want to save the Excel file
#excel_file_path = "source.xlsx"

# Write the grouped DataFrame to an Excel file
#grouped_df.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
                                                  
                                                    What food is highest in magnesium ?_Whole grains  \
Where do you get the knowledge about Magnesium ...                                                     
Magnesium supplements Labels                                                                      20   
More than one answer is true                                                                      30   
Scientific Researches                                                                             58   
Self experience                                                                                    6   
University courses                                                                                48   

                                                    What are the signs of low magnesium ?_All of above  \
Where do you get the knowledge about Magnesium ...                                                       
Magnesium supplements Labels                                                                        1    
More than one answer is true                                                                       10    
Scientific Researches                                                                              10    
Self experience                                                                                     0    
University courses                                                                                 13    

                                                    What are the health condition does magnesium used for  ?_All of above  \
Where do you get the knowledge about Magnesium ...                                                                          
Magnesium supplements Labels                                                                        4                       
More than one answer is true                                                                       15                       
Scientific Researches                                                                              14                       
Self experience                                                                                     2                       
University courses                                                                                 19                       

                                                    Can magnesium maintained body biological clock balanced ?_True  \
Where do you get the knowledge about Magnesium ...                                                                   
Magnesium supplements Labels                                                                       43                
More than one answer is true                                                                       49                
Scientific Researches                                                                              82                
Self experience                                                                                    30                
University courses                                                                                 76                

                                                    Does magnesium help with anxiety ?_Yes  \
Where do you get the knowledge about Magnesium ...                                           
Magnesium supplements Labels                                                            33   
More than one answer is true                                                            28   
Scientific Researches                                                                   59   
Self experience                                                                         20   
University courses                                                                      48   

                                                    What is the main health benefit for Magnesium L-threonate ?_Brain health  \
Where do you get the knowledge about Magnesium ...                                                                             
Magnesium supplements Labels                                                                        6                          
More than one answer is true                                                                       11                          
Scientific Researches                                                                               9                          
Self experience                                                                                     3                          
University courses                                                                                 14                          

                                                    To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
Where do you get the knowledge about Magnesium ...                                                                                                                         
Magnesium supplements Labels                                                                        2                                                                      
More than one answer is true                                                                       11                                                                      
Scientific Researches                                                                               6                                                                      
Self experience                                                                                     1                                                                      
University courses                                                                                  9                                                                      

                                                    Magnesium oxide is best indicated for ?_Constipation  \
Where do you get the knowledge about Magnesium ...                                                         
Magnesium supplements Labels                                                                        6      
More than one answer is true                                                                       17      
Scientific Researches                                                                              11      
Self experience                                                                                     1      
University courses                                                                                 15      

                                                    What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
Where do you get the knowledge about Magnesium ...                                                                                                             
Magnesium supplements Labels                                                                        4                                                          
More than one answer is true                                                                       13                                                          
Scientific Researches                                                                              10                                                          
Self experience                                                                                     3                                                          
University courses                                                                                 10                                                          

                                                    If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
Where do you get the knowledge about Magnesium ...                                                                                                                                                                             
Magnesium supplements Labels                                                                        9                                                                                                                          
More than one answer is true                                                                        8                                                                                                                          
Scientific Researches                                                                              19                                                                                                                          
Self experience                                                                                     7                                                                                                                          
University courses                                                                                 26                                                                                                                          

                                                    Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
Where do you get the knowledge about Magnesium ...                                                                                                    
Magnesium supplements Labels                                                                       27                                                 
More than one answer is true                                                                       29                                                 
Scientific Researches                                                                              39                                                 
Self experience                                                                                    23                                                 
University courses                                                                                 44                                                 

                                                    Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
Where do you get the knowledge about Magnesium ...                                                                      
Magnesium supplements Labels                                                                       46                   
More than one answer is true                                                                       51                   
Scientific Researches                                                                              82                   
Self experience                                                                                    33                   
University courses                                                                                 77                   

                                                    Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
Where do you get the knowledge about Magnesium ...                                                            
Magnesium supplements Labels                                                                       28         
More than one answer is true                                                                       25         
Scientific Researches                                                                              49         
Self experience                                                                                    16         
University courses                                                                                 37         

                                                    What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
Where do you get the knowledge about Magnesium ...                                                                                                
Magnesium supplements Labels                                                                        2                                             
More than one answer is true                                                                       14                                             
Scientific Researches                                                                              13                                             
Self experience                                                                                     2                                             
University courses                                                                                 16                                             

                                                    Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
Where do you get the knowledge about Magnesium ...                                                                                                      
Magnesium supplements Labels                                                                       10                                                   
More than one answer is true                                                                       31                                                   
Scientific Researches                                                                              29                                                   
Self experience                                                                                     7                                                   
University courses                                                                                 37                                                   
In [105]:
# Group by source of knowledge and calculate the count of each boolean column
grouped_df = new_df.groupby('Where do you get the knowledge about Magnesium benefits ?')[selected_columns].count()

# Subtract the sum of true values from the total count to get the sum of false values
grouped_df_false = grouped_df - new_df.groupby('Where do you get the knowledge about Magnesium benefits ?')[selected_columns].sum()

# Print the grouped DataFrame for false values
print(grouped_df_false)

# Specify the file path where you want to save the Excel file
#excel_file_path = "source_false.xlsx"

# Write the grouped DataFrame for false values to an Excel file
#grouped_df_false.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
                                                  

                                                    Years of Experience   \
Where do you get the knowledge about Magnesium ...                         
Magnesium supplements Labels                                        -506   
More than one answer is true                                        -496   
Scientific Researches                                               -957   
Self experience                                                     -319   
University courses                                                  -745   

                                                    What food is highest in magnesium ?_Whole grains  \
Where do you get the knowledge about Magnesium ...                                                     
Magnesium supplements Labels                                                                      30   
More than one answer is true                                                                      27   
Scientific Researches                                                                             33   
Self experience                                                                                   28   
University courses                                                                                36   

                                                    What are the signs of low magnesium ?_All of above  \
Where do you get the knowledge about Magnesium ...                                                       
Magnesium supplements Labels                                                                       49    
More than one answer is true                                                                       47    
Scientific Researches                                                                              81    
Self experience                                                                                    34    
University courses                                                                                 71    

                                                    What are the health condition does magnesium used for  ?_All of above  \
Where do you get the knowledge about Magnesium ...                                                                          
Magnesium supplements Labels                                                                       46                       
More than one answer is true                                                                       42                       
Scientific Researches                                                                              77                       
Self experience                                                                                    32                       
University courses                                                                                 65                       

                                                    Can magnesium maintained body biological clock balanced ?_True  \
Where do you get the knowledge about Magnesium ...                                                                   
Magnesium supplements Labels                                                                        7                
More than one answer is true                                                                        8                
Scientific Researches                                                                               9                
Self experience                                                                                     4                
University courses                                                                                  8                

                                                    Does magnesium help with anxiety ?_Yes  \
Where do you get the knowledge about Magnesium ...                                           
Magnesium supplements Labels                                                            17   
More than one answer is true                                                            29   
Scientific Researches                                                                   32   
Self experience                                                                         14   
University courses                                                                      36   

                                                    What is the main health benefit for Magnesium L-threonate ?_Brain health  \
Where do you get the knowledge about Magnesium ...                                                                             
Magnesium supplements Labels                                                                       44                          
More than one answer is true                                                                       46                          
Scientific Researches                                                                              82                          
Self experience                                                                                    31                          
University courses                                                                                 70                          

                                                    To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
Where do you get the knowledge about Magnesium ...                                                                                                                         
Magnesium supplements Labels                                                                       48                                                                      
More than one answer is true                                                                       46                                                                      
Scientific Researches                                                                              85                                                                      
Self experience                                                                                    33                                                                      
University courses                                                                                 75                                                                      

                                                    Magnesium oxide is best indicated for ?_Constipation  \
Where do you get the knowledge about Magnesium ...                                                         
Magnesium supplements Labels                                                                       44      
More than one answer is true                                                                       40      
Scientific Researches                                                                              80      
Self experience                                                                                    33      
University courses                                                                                 69      

                                                    What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
Where do you get the knowledge about Magnesium ...                                                                                                             
Magnesium supplements Labels                                                                       46                                                          
More than one answer is true                                                                       44                                                          
Scientific Researches                                                                              81                                                          
Self experience                                                                                    31                                                          
University courses                                                                                 74                                                          

                                                    If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
Where do you get the knowledge about Magnesium ...                                                                                                                                                                             
Magnesium supplements Labels                                                                       41                                                                                                                          
More than one answer is true                                                                       49                                                                                                                          
Scientific Researches                                                                              72                                                                                                                          
Self experience                                                                                    27                                                                                                                          
University courses                                                                                 58                                                                                                                          

                                                    Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
Where do you get the knowledge about Magnesium ...                                                                                                    
Magnesium supplements Labels                                                                       23                                                 
More than one answer is true                                                                       28                                                 
Scientific Researches                                                                              52                                                 
Self experience                                                                                    11                                                 
University courses                                                                                 40                                                 

                                                    Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
Where do you get the knowledge about Magnesium ...                                                                      
Magnesium supplements Labels                                                                        4                   
More than one answer is true                                                                        6                   
Scientific Researches                                                                               9                   
Self experience                                                                                     1                   
University courses                                                                                  7                   

                                                    Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
Where do you get the knowledge about Magnesium ...                                                            
Magnesium supplements Labels                                                                       22         
More than one answer is true                                                                       32         
Scientific Researches                                                                              42         
Self experience                                                                                    18         
University courses                                                                                 47         

                                                    What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
Where do you get the knowledge about Magnesium ...                                                                                                
Magnesium supplements Labels                                                                       48                                             
More than one answer is true                                                                       43                                             
Scientific Researches                                                                              78                                             
Self experience                                                                                    32                                             
University courses                                                                                 68                                             

                                                    Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
Where do you get the knowledge about Magnesium ...                                                                                                      
Magnesium supplements Labels                                                                       40                                                   
More than one answer is true                                                                       26                                                   
Scientific Researches                                                                              62                                                   
Self experience                                                                                    27                                                   
University courses                                                                                 47                                                   
In [106]:
# Define the bins for age categories
bins = [21, 34, 44, float('inf')]  # Define the bin edges

# Define labels for the age categories
labels = ['22-34', '35-44', '45+']

# Use pd.cut() to create a new column 'Age Group' by categorizing the 'Your Age' column
new_df['Age Group'] = pd.cut(new_df['Your Age'], bins=bins, labels=labels, right=False)

# Print the DataFrame with the new 'Age Group' column
print(new_df[['Your Age', 'Age Group']])
     Your Age Age Group
0          35     35-44
1          42     35-44
2          44       45+
3          25     22-34
4          45       45+
..        ...       ...
315        25     22-34
316        26     22-34
317        46       45+
318        31     22-34
319        30     22-34

[316 rows x 2 columns]
In [114]:
# Group by education level and calculate the sum of True values for each boolean column
grouped_df = new_df.groupby('Age Group')[selected_columns].sum()

# Print the grouped DataFrame
print(grouped_df)

#excel_file_path = "age_C.xlsx"

# Write the grouped DataFrame for false values to an Excel file
#grouped_df.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
           Your Age  Years of Experience   \
Age Group                                   
22-34          5323                  1081   
35-44          2918                  1081   
45+            2588                  1177   

           What food is highest in magnesium ?_Whole grains  \
Age Group                                                     
22-34                                                    84   
35-44                                                    44   
45+                                                      34   

           What are the signs of low magnesium ?_All of above  \
Age Group                                                       
22-34                                                     20    
35-44                                                      6    
45+                                                        8    

           What are the health condition does magnesium used for  ?_All of above  \
Age Group                                                                          
22-34                                                     30                       
35-44                                                     11                       
45+                                                       13                       

           Can magnesium maintained body biological clock balanced ?_True  \
Age Group                                                                   
22-34                                                    167                
35-44                                                     70                
45+                                                       43                

           Does magnesium help with anxiety ?_Yes  \
Age Group                                           
22-34                                         109   
35-44                                          48   
45+                                            31   

           What is the main health benefit for Magnesium L-threonate ?_Brain health  \
Age Group                                                                             
22-34                                                     24                          
35-44                                                     12                          
45+                                                        7                          

           To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
Age Group                                                                                                                         
22-34                                                     16                                                                      
35-44                                                      9                                                                      
45+                                                        4                                                                      

           Magnesium oxide is best indicated for ?_Constipation  \
Age Group                                                         
22-34                                                     31      
35-44                                                     14      
45+                                                        5      

           What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
Age Group                                                                                                             
22-34                                                     24                                                          
35-44                                                      9                                                          
45+                                                        7                                                          

           If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
Age Group                                                                                                                                                                             
22-34                                                     41                                                                                                                          
35-44                                                     18                                                                                                                          
45+                                                       10                                                                                                                          

           Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
Age Group                                                                                                    
22-34                                                    103                                                 
35-44                                                     37                                                 
45+                                                       22                                                 

           Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
Age Group                                                                      
22-34                                                    178                   
35-44                                                     67                   
45+                                                       44                   

           Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
Age Group                                                            
22-34                                                     96         
35-44                                                     28         
45+                                                       31         

           What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
Age Group                                                                                                
22-34                                                     21                                             
35-44                                                     18                                             
45+                                                        8                                             

           Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
Age Group                                                                                                      
22-34                                                     69                                                   
35-44                                                     29                                                   
45+                                                       16                                                   
C:\Users\samir\AppData\Local\Temp\ipykernel_12560\3542419782.py:2: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  grouped_df = new_df.groupby('Age Group')[selected_columns].sum()
In [115]:
grouped_df = new_df.groupby('Age Group')[selected_columns].count()

# Subtract the sum of true values from the total count to get the sum of false values
grouped_df_false = grouped_df - new_df.groupby('Age Group')[selected_columns].sum()

# Print the grouped DataFrame for false values
print(grouped_df_false)




#excel_file_path = "age_w.xlsx"

# Write the grouped DataFrame for false values to an Excel file
#grouped_df_false.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
           Your Age  Years of Experience   \
Age Group                                   
22-34         -5136                  -894   
35-44         -2841                 -1004   
45+           -2536                 -1125   

           What food is highest in magnesium ?_Whole grains  \
Age Group                                                     
22-34                                                   103   
35-44                                                    33   
45+                                                      18   

           What are the signs of low magnesium ?_All of above  \
Age Group                                                       
22-34                                                    167    
35-44                                                     71    
45+                                                       44    

           What are the health condition does magnesium used for  ?_All of above  \
Age Group                                                                          
22-34                                                    157                       
35-44                                                     66                       
45+                                                       39                       

           Can magnesium maintained body biological clock balanced ?_True  \
Age Group                                                                   
22-34                                                     20                
35-44                                                      7                
45+                                                        9                

           Does magnesium help with anxiety ?_Yes  \
Age Group                                           
22-34                                          78   
35-44                                          29   
45+                                            21   

           What is the main health benefit for Magnesium L-threonate ?_Brain health  \
Age Group                                                                             
22-34                                                    163                          
35-44                                                     65                          
45+                                                       45                          

           To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
Age Group                                                                                                                         
22-34                                                    171                                                                      
35-44                                                     68                                                                      
45+                                                       48                                                                      

           Magnesium oxide is best indicated for ?_Constipation  \
Age Group                                                         
22-34                                                    156      
35-44                                                     63      
45+                                                       47      

           What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
Age Group                                                                                                             
22-34                                                    163                                                          
35-44                                                     68                                                          
45+                                                       45                                                          

           If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
Age Group                                                                                                                                                                             
22-34                                                    146                                                                                                                          
35-44                                                     59                                                                                                                          
45+                                                       42                                                                                                                          

           Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
Age Group                                                                                                    
22-34                                                     84                                                 
35-44                                                     40                                                 
45+                                                       30                                                 

           Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
Age Group                                                                      
22-34                                                      9                   
35-44                                                     10                   
45+                                                        8                   

           Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
Age Group                                                            
22-34                                                     91         
35-44                                                     49         
45+                                                       21         

           What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
Age Group                                                                                                
22-34                                                    166                                             
35-44                                                     59                                             
45+                                                       44                                             

           Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
Age Group                                                                                                      
22-34                                                    118                                                   
35-44                                                     48                                                   
45+                                                       36                                                   
C:\Users\samir\AppData\Local\Temp\ipykernel_12560\2716774390.py:1: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  grouped_df = new_df.groupby('Age Group')[selected_columns].count()
C:\Users\samir\AppData\Local\Temp\ipykernel_12560\2716774390.py:4: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  grouped_df_false = grouped_df - new_df.groupby('Age Group')[selected_columns].sum()
In [116]:
# Define the bins for the categories
bins = [-1, 10, 20, float('inf')]  # -1 is for 0, float('inf') is for 20+

# Define the labels for the categories
labels = ['0-10', '11-20', '20+']

# Create a new column with the categorized year of experience
new_df['Experience Category'] = pd.cut(new_df['Years of Experience '], bins=bins, labels=labels, right=False)

# Display the DataFrame with the new column
print(new_df[['Years of Experience ', 'Experience Category']])
     Years of Experience  Experience Category
0                      12               11-20
1                      15               11-20
2                      20                 20+
3                       2                0-10
4                      13               11-20
..                    ...                 ...
315                     3                0-10
316                     4                0-10
317                    26                 20+
318                     8                0-10
319                     8                0-10

[316 rows x 2 columns]
In [117]:
# Group by education level and calculate the sum of True values for each boolean column
grouped_df = new_df.groupby('Experience Category')[selected_columns].sum()

# Print the grouped DataFrame
print(grouped_df)

#excel_file_path = "Experience_C.xlsx"

# Write the grouped DataFrame for false values to an Excel file
#grouped_df.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
                     Your Age  Years of Experience   \
Experience Category                                   
0-10                     4995                   918   
11-20                    3447                  1240   
20+                      2387                  1181   

                     What food is highest in magnesium ?_Whole grains  \
Experience Category                                                     
0-10                                                               86   
11-20                                                              44   
20+                                                                32   

                     What are the signs of low magnesium ?_All of above  \
Experience Category                                                       
0-10                                                                18    
11-20                                                                6    
20+                                                                 10    

                     What are the health condition does magnesium used for  ?_All of above  \
Experience Category                                                                          
0-10                                                                25                       
11-20                                                               15                       
20+                                                                 14                       

                     Can magnesium maintained body biological clock balanced ?_True  \
Experience Category                                                                   
0-10                                                               155                
11-20                                                               83                
20+                                                                 42                

                     Does magnesium help with anxiety ?_Yes  \
Experience Category                                           
0-10                                                    109   
11-20                                                    49   
20+                                                      30   

                     What is the main health benefit for Magnesium L-threonate ?_Brain health  \
Experience Category                                                                             
0-10                                                                19                          
11-20                                                               16                          
20+                                                                  8                          

                     To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
Experience Category                                                                                                                         
0-10                                                                14                                                                      
11-20                                                               12                                                                      
20+                                                                  3                                                                      

                     Magnesium oxide is best indicated for ?_Constipation  \
Experience Category                                                         
0-10                                                                24      
11-20                                                               20      
20+                                                                  6      

                     What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
Experience Category                                                                                                             
0-10                                                                21                                                          
11-20                                                               12                                                          
20+                                                                  7                                                          

                     If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
Experience Category                                                                                                                                                                             
0-10                                                                38                                                                                                                          
11-20                                                               21                                                                                                                          
20+                                                                 10                                                                                                                          

                     Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
Experience Category                                                                                                    
0-10                                                               100                                                 
11-20                                                               43                                                 
20+                                                                 19                                                 

                     Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
Experience Category                                                                      
0-10                                                               168                   
11-20                                                               81                   
20+                                                                 40                   

                     Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
Experience Category                                                            
0-10                                                                93         
11-20                                                               36         
20+                                                                 26         

                     What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
Experience Category                                                                                                
0-10                                                                18                                             
11-20                                                               17                                             
20+                                                                 12                                             

                     Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
Experience Category                                                                                                      
0-10                                                                60                                                   
11-20                                                               34                                                   
20+                                                                 20                                                   
C:\Users\samir\AppData\Local\Temp\ipykernel_12560\3879462704.py:2: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  grouped_df = new_df.groupby('Experience Category')[selected_columns].sum()
In [118]:
grouped_df = new_df.groupby('Experience Category')[selected_columns].count()

# Subtract the sum of true values from the total count to get the sum of false values
grouped_df_false = grouped_df - new_df.groupby('Experience Category')[selected_columns].sum()

# Print the grouped DataFrame for false values
print(grouped_df_false)




#excel_file_path = "Experience_w.xlsx"

# Write the grouped DataFrame for false values to an Excel file
#grouped_df_false.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
                     Your Age  Years of Experience   \
Experience Category                                   
0-10                    -4819                  -742   
11-20                   -3356                 -1149   
20+                     -2338                 -1132   

                     What food is highest in magnesium ?_Whole grains  \
Experience Category                                                     
0-10                                                               90   
11-20                                                              47   
20+                                                                17   

                     What are the signs of low magnesium ?_All of above  \
Experience Category                                                       
0-10                                                               158    
11-20                                                               85    
20+                                                                 39    

                     What are the health condition does magnesium used for  ?_All of above  \
Experience Category                                                                          
0-10                                                               151                       
11-20                                                               76                       
20+                                                                 35                       

                     Can magnesium maintained body biological clock balanced ?_True  \
Experience Category                                                                   
0-10                                                                21                
11-20                                                                8                
20+                                                                  7                

                     Does magnesium help with anxiety ?_Yes  \
Experience Category                                           
0-10                                                     67   
11-20                                                    42   
20+                                                      19   

                     What is the main health benefit for Magnesium L-threonate ?_Brain health  \
Experience Category                                                                             
0-10                                                               157                          
11-20                                                               75                          
20+                                                                 41                          

                     To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate  \
Experience Category                                                                                                                         
0-10                                                               162                                                                      
11-20                                                               79                                                                      
20+                                                                 46                                                                      

                     Magnesium oxide is best indicated for ?_Constipation  \
Experience Category                                                         
0-10                                                               152      
11-20                                                               71      
20+                                                                 43      

                     What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male  \
Experience Category                                                                                                             
0-10                                                               155                                                          
11-20                                                               79                                                          
20+                                                                 42                                                          

                     If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours  \
Experience Category                                                                                                                                                                             
0-10                                                               138                                                                                                                          
11-20                                                               70                                                                                                                          
20+                                                                 39                                                                                                                          

                     Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders  \
Experience Category                                                                                                    
0-10                                                                76                                                 
11-20                                                               48                                                 
20+                                                                 30                                                 

                     Can Large doses of vitamin D induce severe depletion of Mg ?_True  \
Experience Category                                                                      
0-10                                                                 8                   
11-20                                                               10                   
20+                                                                  9                   

                     Is Magnesium safe for pregnant in Eclampsia cases ?_1.0  \
Experience Category                                                            
0-10                                                                83         
11-20                                                               55         
20+                                                                 23         

                     What is the side effect behind consuming Magnesium supplements for long term ?_All of above  \
Experience Category                                                                                                
0-10                                                               158                                             
11-20                                                               74                                             
20+                                                                 37                                             

                     Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true  
Experience Category                                                                                                      
0-10                                                               116                                                   
11-20                                                               57                                                   
20+                                                                 29                                                   
C:\Users\samir\AppData\Local\Temp\ipykernel_12560\773932588.py:1: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  grouped_df = new_df.groupby('Experience Category')[selected_columns].count()
C:\Users\samir\AppData\Local\Temp\ipykernel_12560\773932588.py:4: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  grouped_df_false = grouped_df - new_df.groupby('Experience Category')[selected_columns].sum()
In [119]:
# Create an empty dictionary to store the counts
boolean_counts = {}

# Iterate over each boolean column
for column in new_df.columns:
    # Calculate value counts for the column
    counts = new_df[column].value_counts()
    
    # Store the counts in the dictionary
    boolean_counts[column] = counts

# Print the counts
for column, counts in boolean_counts.items():
    print(f"Column: {column}")
    print(counts)
    print()
Column: Your Gender 
Your Gender 
Female    227
Male       89
Name: count, dtype: int64

Column: Educational Level 
Educational Level 
Master's Degree      180
Bachelor's Degree    111
PHD degree            25
Name: count, dtype: int64

Column: Years of Experience 
Years of Experience 
6     30
4     27
5     26
7     19
3     19
8     18
2     17
12    15
9     14
11    13
10    13
13    11
22     8
20     8
19     8
15     8
18     7
14     7
23     7
1      6
24     5
25     5
16     5
17     4
32     3
21     3
27     3
29     2
26     2
30     1
31     1
28     1
Name: count, dtype: int64

Column: Where do you get the knowledge about Magnesium benefits ?
Where do you get the knowledge about Magnesium benefits ?
Scientific Researches           91
University courses              84
More than one answer is true    57
Magnesium supplements Labels    50
Self experience                 34
Name: count, dtype: int64

Column: Your Age
Your Age
29    31
30    25
28    23
31    19
26    18
27    16
25    15
33    15
34    15
40    10
32    10
36     9
35     9
24     9
41     8
39     8
42     7
45     7
52     6
46     6
44     6
38     4
43     4
49     3
47     3
53     3
22     3
50     3
23     3
54     3
37     3
55     2
48     2
56     2
59     2
51     1
57     1
58     1
60     1
Name: count, dtype: int64

Column: What food is highest in magnesium ?_Whole grains
What food is highest in magnesium ?_Whole grains
True     162
False    154
Name: count, dtype: int64

Column: What are the signs of low magnesium ?_All of above
What are the signs of low magnesium ?_All of above
False    282
True      34
Name: count, dtype: int64

Column: What are the health condition does magnesium used for  ?_All of above
What are the health condition does magnesium used for  ?_All of above
False    262
True      54
Name: count, dtype: int64

Column: Can magnesium maintained body biological clock balanced ?_True
Can magnesium maintained body biological clock balanced ?_True
True     280
False     36
Name: count, dtype: int64

Column: Does magnesium help with anxiety ?_Yes
Does magnesium help with anxiety ?_Yes
True     188
False    128
Name: count, dtype: int64

Column: What is the main health benefit for Magnesium L-threonate ?_Brain health
What is the main health benefit for Magnesium L-threonate ?_Brain health
False    273
True      43
Name: count, dtype: int64

Column: To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate
To improve sleep and get rid of insomnia , What is the best type of magnesium you will counsel ?_Magnesium glycinate
False    287
True      29
Name: count, dtype: int64

Column: Magnesium oxide is best indicated for ?_Constipation
Magnesium oxide is best indicated for ?_Constipation
False    266
True      50
Name: count, dtype: int64

Column: What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male
What is the recommended dose of Magnesium supplements that patient needs ?_320 for Female & 420 for Male
False    276
True      40
Name: count, dtype: int64

Column: If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours
If patient was given doxycyclin for acne treatment and he use Magnesium regularly , What is the best plan to do ?_Separate the time of the dose by at least 2 to 3 hours
False    247
True      69
Name: count, dtype: int64

Column: Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders
Which case does Magnesium taken with caution and the dose should be adjusted ?_Kidney disorders
True     162
False    154
Name: count, dtype: int64

Column: Can Large doses of vitamin D induce severe depletion of Mg ?_True
Can Large doses of vitamin D induce severe depletion of Mg ?_True
True     289
False     27
Name: count, dtype: int64

Column: Is Magnesium safe for pregnant in Eclampsia cases ?_1.0
Is Magnesium safe for pregnant in Eclampsia cases ?_1.0
False    161
True     155
Name: count, dtype: int64

Column: What is the side effect behind consuming Magnesium supplements for long term ?_All of above
What is the side effect behind consuming Magnesium supplements for long term ?_All of above
False    269
True      47
Name: count, dtype: int64

Column: Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true
Why do you think the reasons behind side effects of using Magnesium ?_More than one answer is true
False    202
True     114
Name: count, dtype: int64

Column: Age Group
Age Group
22-34    187
35-44     77
45+       52
Name: count, dtype: int64

Column: Experience Category
Experience Category
0-10     176
11-20     91
20+       49
Name: count, dtype: int64

In [120]:
# Iterate over each column and plot a pie chart
for column in new_df.columns:
    try:
        plt.figure()
        counts = df[column].value_counts()
        plt.pie(counts, labels=counts.index, autopct='%1.1f%%', startangle=140)
        plt.title(f'Proportion of Values for {column}')
        plt.axis('equal')
        plt.show()
    except Exception as e:
        print(f"Error plotting pie chart for column '{column}': {e}")
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>